Java Code Examples for java.rmi.server.UID

The following examples show how to use java.rmi.server.UID. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: JNDI-Injection-Exploit   Source File: RMIRefServer.java    License: MIT License 6 votes vote down vote up
private void doMessage ( Socket s, DataInputStream in, DataOutputStream out ) throws Exception {
    System.out.println(getLocalTime() + " [RMISERVER]  >> Reading message...");

    int op = in.read();

    switch ( op ) {
    case TransportConstants.Call:
        // service incoming RMI call
        doCall(in, out);
        break;

    case TransportConstants.Ping:
        // send ack for ping
        out.writeByte(TransportConstants.PingAck);
        break;

    case TransportConstants.DGCAck:
        UID.read(in);
        break;

    default:
        throw new IOException(getLocalTime() + " [RMISERVER]  >> unknown transport op " + op);
    }

    s.close();
}
 
Example 2
Source Project: ysoserial   Source File: JRMPListener.java    License: MIT License 6 votes vote down vote up
private void doMessage ( Socket s, DataInputStream in, DataOutputStream out, Object payload ) throws Exception {
    System.err.println("Reading message...");

    int op = in.read();

    switch ( op ) {
    case TransportConstants.Call:
        // service incoming RMI call
        doCall(in, out, payload);
        break;

    case TransportConstants.Ping:
        // send ack for ping
        out.writeByte(TransportConstants.PingAck);
        break;

    case TransportConstants.DGCAck:
        UID u = UID.read(in);
        break;

    default:
        throw new IOException("unknown transport op " + op);
    }

    s.close();
}
 
Example 3
Source Project: ysoserial-modified   Source File: JRMPListener.java    License: MIT License 6 votes vote down vote up
private void doMessage ( Socket s, DataInputStream in, DataOutputStream out, Object payload ) throws Exception {
    System.err.println("Reading message...");

    int op = in.read();

    switch ( op ) {
    case TransportConstants.Call:
        // service incoming RMI call
        doCall(in, out, payload);
        break;

    case TransportConstants.Ping:
        // send ack for ping
        out.writeByte(TransportConstants.PingAck);
        break;

    case TransportConstants.DGCAck:
        UID u = UID.read(in);
        break;

    default:
        throw new IOException("unknown transport op " + op);
    }

    s.close();
}
 
Example 4
Source Project: marshalsec   Source File: RMIRefServer.java    License: MIT License 6 votes vote down vote up
private void doMessage ( Socket s, DataInputStream in, DataOutputStream out ) throws Exception {
    System.err.println("Reading message...");

    int op = in.read();

    switch ( op ) {
    case TransportConstants.Call:
        // service incoming RMI call
        doCall(in, out);
        break;

    case TransportConstants.Ping:
        // send ack for ping
        out.writeByte(TransportConstants.PingAck);
        break;

    case TransportConstants.DGCAck:
        UID.read(in);
        break;

    default:
        throw new IOException("unknown transport op " + op);
    }

    s.close();
}
 
Example 5
Source Project: jdk8u-dev-jdk   Source File: DGCAckHandler.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Causes the DGCAckHandler associated with the specified UID to
 * release its references.
 **/
public static void received(UID id) {
    DGCAckHandler h = idTable.remove(id);
    if (h != null) {
        h.release();
    }
}
 
Example 6
/**
 * Constructs an marshal output stream using the underlying
 * stream associated with the connection, the parameter c.
 * @param c is the Connection object associated with the
 * ConnectionOutputStream object being constructed
 * @param resultStream indicates whether this stream is used
 * to marshal return results
 */
ConnectionOutputStream(Connection conn, boolean resultStream)
    throws IOException
{
    super(conn.getOutputStream());
    this.conn = conn;
    this.resultStream = resultStream;
    ackID = resultStream ? new UID() : null;
}
 
Example 7
Source Project: jdk8u_jdk   Source File: DGCImpl_Stub.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * ObjectInputFilter to filter DGCClient return value (a Lease).
 * The list of acceptable classes is very short and explicit.
 * The depth and array sizes are limited.
 * <p>
 * The filter must accept normal and exception returns.
 * A DGC server may throw exceptions that may have a cause
 * and suppressed exceptions.
 *
 * @param filterInfo access to class, arrayLength, etc.
 * @return  {@link ObjectInputFilter.Status#ALLOWED} if allowed,
 *          {@link ObjectInputFilter.Status#REJECTED} if rejected,
 *          otherwise {@link ObjectInputFilter.Status#UNDECIDED}
 */
private static ObjectInputFilter.Status leaseFilter(ObjectInputFilter.FilterInfo filterInfo) {

    if (filterInfo.depth() > DGCCLIENT_MAX_DEPTH) {
        return ObjectInputFilter.Status.REJECTED;
    }
    Class<?> clazz = filterInfo.serialClass();
    if (clazz != null) {
        while (clazz.isArray()) {
            if (filterInfo.arrayLength() >= 0 && filterInfo.arrayLength() > DGCCLIENT_MAX_ARRAY_SIZE) {
                return ObjectInputFilter.Status.REJECTED;
            }
            // Arrays are allowed depending on the component type
            clazz = clazz.getComponentType();
        }
        if (clazz.isPrimitive()) {
            // Arrays of primitives are allowed
            return ObjectInputFilter.Status.ALLOWED;
        }
        return (clazz == UID.class ||
                clazz == VMID.class ||
                clazz == Lease.class ||
                (Throwable.class.isAssignableFrom(clazz) &&
                        clazz.getClassLoader() ==
                        Object.class.getClassLoader()) ||
                clazz == StackTraceElement.class ||
                clazz == ArrayList.class ||     // for suppressed exceptions, if any
                clazz == Object.class ||
                clazz.getName().equals("java.util.Collections$UnmodifiableList") ||
                clazz.getName().equals("java.util.Collections$UnmodifiableCollection") ||
                clazz.getName().equals("java.util.Collections$UnmodifiableRandomAccessList"))
                ? ObjectInputFilter.Status.ALLOWED
                : ObjectInputFilter.Status.REJECTED;
    }
    // Not a class, not size limited
    return ObjectInputFilter.Status.UNDECIDED;
}
 
Example 8
Source Project: TencentKona-8   Source File: DGCAckHandler.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Causes the DGCAckHandler associated with the specified UID to
 * release its references.
 **/
public static void received(UID id) {
    DGCAckHandler h = idTable.remove(id);
    if (h != null) {
        h.release();
    }
}
 
Example 9
/**
 * Constructs an marshal output stream using the underlying
 * stream associated with the connection, the parameter c.
 * @param c is the Connection object associated with the
 * ConnectionOutputStream object being constructed
 * @param resultStream indicates whether this stream is used
 * to marshal return results
 */
ConnectionOutputStream(Connection conn, boolean resultStream)
    throws IOException
{
    super(conn.getOutputStream());
    this.conn = conn;
    this.resultStream = resultStream;
    ackID = resultStream ? new UID() : null;
}
 
Example 10
/**
 * Constructs an marshal output stream using the underlying
 * stream associated with the connection, the parameter c.
 * @param c is the Connection object associated with the
 * ConnectionOutputStream object being constructed
 * @param resultStream indicates whether this stream is used
 * to marshal return results
 */
ConnectionOutputStream(Connection conn, boolean resultStream)
    throws IOException
{
    super(conn.getOutputStream());
    this.conn = conn;
    this.resultStream = resultStream;
    ackID = resultStream ? new UID() : null;
}
 
Example 11
Source Project: jdk8u60   Source File: DGCAckHandler.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Causes the DGCAckHandler associated with the specified UID to
 * release its references.
 **/
public static void received(UID id) {
    DGCAckHandler h = idTable.remove(id);
    if (h != null) {
        h.release();
    }
}
 
Example 12
/**
 * Constructs an marshal output stream using the underlying
 * stream associated with the connection, the parameter c.
 * @param c is the Connection object associated with the
 * ConnectionOutputStream object being constructed
 * @param resultStream indicates whether this stream is used
 * to marshal return results
 */
ConnectionOutputStream(Connection conn, boolean resultStream)
    throws IOException
{
    super(conn.getOutputStream());
    this.conn = conn;
    this.resultStream = resultStream;
    ackID = resultStream ? new UID() : null;
}
 
Example 13
/**
 * Constructs an marshal output stream using the underlying
 * stream associated with the connection, the parameter c.
 * @param c is the Connection object associated with the
 * ConnectionOutputStream object being constructed
 * @param resultStream indicates whether this stream is used
 * to marshal return results
 */
ConnectionOutputStream(Connection conn, boolean resultStream)
    throws IOException
{
    super(conn.getOutputStream());
    this.conn = conn;
    this.resultStream = resultStream;
    ackID = resultStream ? new UID() : null;
}
 
Example 14
Source Project: openjdk-jdk8u   Source File: DGCImpl.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * ObjectInputFilter to filter DGC input objects.
 * The list of acceptable classes is very short and explicit.
 * The depth and array sizes are limited.
 *
 * @param filterInfo access to class, arrayLength, etc.
 * @return  {@link ObjectInputFilter.Status#ALLOWED} if allowed,
 *          {@link ObjectInputFilter.Status#REJECTED} if rejected,
 *          otherwise {@link ObjectInputFilter.Status#UNDECIDED}
 */
private static ObjectInputFilter.Status checkInput(ObjectInputFilter.FilterInfo filterInfo) {
    if (dgcFilter != null) {
        ObjectInputFilter.Status status = dgcFilter.checkInput(filterInfo);
        if (status != ObjectInputFilter.Status.UNDECIDED) {
            // The DGC filter can override the built-in white-list
            return status;
        }
    }

    if (filterInfo.depth() > DGC_MAX_DEPTH) {
        return ObjectInputFilter.Status.REJECTED;
    }
    Class<?> clazz = filterInfo.serialClass();
    if (clazz != null) {
        while (clazz.isArray()) {
            if (filterInfo.arrayLength() >= 0 && filterInfo.arrayLength() > DGC_MAX_ARRAY_SIZE) {
                return ObjectInputFilter.Status.REJECTED;
            }
            // Arrays are allowed depending on the component type
            clazz = clazz.getComponentType();
        }
        if (clazz.isPrimitive()) {
            // Arrays of primitives are allowed
            return ObjectInputFilter.Status.ALLOWED;
        }
        return (clazz == ObjID.class ||
                clazz == UID.class ||
                clazz == VMID.class ||
                clazz == Lease.class)
                ? ObjectInputFilter.Status.ALLOWED
                : ObjectInputFilter.Status.REJECTED;
    }
    // Not a class, not size limited
    return ObjectInputFilter.Status.UNDECIDED;
}
 
Example 15
Source Project: suro   Source File: FileNameFormatter.java    License: Apache License 2.0 5 votes vote down vote up
/**
 *
 * @param dir directory path where the files are written
 * @return full file path with the directory suffixed
 */
public static String get(String dir) {
    StringBuilder sb = new StringBuilder(dir);
    if (!dir.endsWith("/")) {
        sb.append('/');
    }
    sb.append(fmt.print(new DateTime()))
            .append(localHostAddr)
            .append(new UID().toString());
    return sb.toString().replaceAll("[-:]", "");
}
 
Example 16
/**
 * ObjectInputFilter to filter DGCClient return value (a Lease).
 * The list of acceptable classes is very short and explicit.
 * The depth and array sizes are limited.
 *
 * @param filterInfo access to class, arrayLength, etc.
 * @return  {@link ObjectInputFilter.Status#ALLOWED} if allowed,
 *          {@link ObjectInputFilter.Status#REJECTED} if rejected,
 *          otherwise {@link ObjectInputFilter.Status#UNDECIDED}
 */
private static ObjectInputFilter.Status leaseFilter(ObjectInputFilter.FilterInfo filterInfo) {

    if (filterInfo.depth() > DGCCLIENT_MAX_DEPTH) {
        return ObjectInputFilter.Status.REJECTED;
    }
    Class<?> clazz = filterInfo.serialClass();
    if (clazz != null) {
        while (clazz.isArray()) {
            if (filterInfo.arrayLength() >= 0 && filterInfo.arrayLength() > DGCCLIENT_MAX_ARRAY_SIZE) {
                return ObjectInputFilter.Status.REJECTED;
            }
            // Arrays are allowed depending on the component type
            clazz = clazz.getComponentType();
        }
        if (clazz.isPrimitive()) {
            // Arrays of primitives are allowed
            return ObjectInputFilter.Status.ALLOWED;
        }
        return (clazz == UID.class ||
                clazz == VMID.class ||
                clazz == Lease.class)
                ? ObjectInputFilter.Status.ALLOWED
                : ObjectInputFilter.Status.REJECTED;
    }
    // Not a class, not size limited
    return ObjectInputFilter.Status.UNDECIDED;
}
 
Example 17
/**
 * Constructs an marshal output stream using the underlying
 * stream associated with the connection, the parameter c.
 * @param c is the Connection object associated with the
 * ConnectionOutputStream object being constructed
 * @param resultStream indicates whether this stream is used
 * to marshal return results
 */
ConnectionOutputStream(Connection conn, boolean resultStream)
    throws IOException
{
    super(conn.getOutputStream());
    this.conn = conn;
    this.resultStream = resultStream;
    ackID = resultStream ? new UID() : null;
}
 
Example 18
Source Project: openjdk-8   Source File: DGCAckHandler.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Causes the DGCAckHandler associated with the specified UID to
 * release its references.
 **/
public static void received(UID id) {
    DGCAckHandler h = idTable.remove(id);
    if (h != null) {
        h.release();
    }
}
 
Example 19
Source Project: perf-harness   Source File: DefaultMessageFactory.java    License: MIT License 5 votes vote down vote up
/**
 * Attempts to use as much system info as possible to create a unique 24 byte identifier for the
 * given WorkerThread.  In default mode it uses the UID class (not the best option!) and it is therefore
 * advisable to set <code>-id</code> in which case the tool assumes that this id is globally unique within
 * the test environment and can safely be used to differentiate JVMs.
 * Currently this is
 * unique per worker, but is undefined as to wether it returns the same cid from multiple
 * calls.
 * @param worker The subject for the correlation id.
 * @return A 24-byte array
 * @throws UnknownHostException The local hostname is being used to identify this JVM but could not be looked up
 * (try using <code>-id</code> to avoid the requirement on hostname.
 */
protected byte[] makeCorrelIdAsBytes(WorkerThread worker) throws UnknownHostException {

	String proc_id = Config.parms.getString("id");
	byte[] bytes = new byte[24];
	
	if (proc_id != null && proc_id.length() > 0) {
		// If we have set an ID then use that 
		byte[] b = proc_id.getBytes();
		System.arraycopy( b, 0, bytes, 0, b.length>24?24:b.length );
	} else {
		// we have not set an ID, so attempt to create a random one.
		byte[] addr = InetAddress.getLocalHost().getAddress();
		String uid = new UID().toString();
		if (uid.length() > (22 - addr.length)) {
			uid = uid.substring(0, 22 - addr.length);
		}
	
		System.arraycopy(addr, 0, bytes, 0, addr.length);
		System.arraycopy(uid.toString().getBytes(), 0, bytes, addr.length, uid.length());
	}
	
	// Add on the the thread id
	int threadInt = worker.getThreadNum();
	byte[] threadBytes = String.valueOf(threadInt).getBytes();
	System.arraycopy(threadBytes, 0, bytes, (24 - threadBytes.length), threadBytes.length);

	return bytes;
}
 
Example 20
Source Project: openjdk-jdk9   Source File: DGCImpl_Stub.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * ObjectInputFilter to filter DGCClient return value (a Lease).
 * The list of acceptable classes is very short and explicit.
 * The depth and array sizes are limited.
 *
 * @param filterInfo access to class, arrayLength, etc.
 * @return  {@link ObjectInputFilter.Status#ALLOWED} if allowed,
 *          {@link ObjectInputFilter.Status#REJECTED} if rejected,
 *          otherwise {@link ObjectInputFilter.Status#UNDECIDED}
 */
private static ObjectInputFilter.Status leaseFilter(ObjectInputFilter.FilterInfo filterInfo) {

    if (filterInfo.depth() > DGCCLIENT_MAX_DEPTH) {
        return ObjectInputFilter.Status.REJECTED;
    }
    Class<?> clazz = filterInfo.serialClass();
    if (clazz != null) {
        while (clazz.isArray()) {
            if (filterInfo.arrayLength() >= 0 && filterInfo.arrayLength() > DGCCLIENT_MAX_ARRAY_SIZE) {
                return ObjectInputFilter.Status.REJECTED;
            }
            // Arrays are allowed depending on the component type
            clazz = clazz.getComponentType();
        }
        if (clazz.isPrimitive()) {
            // Arrays of primitives are allowed
            return ObjectInputFilter.Status.ALLOWED;
        }
        return (clazz == UID.class ||
                clazz == VMID.class ||
                clazz == Lease.class)
                ? ObjectInputFilter.Status.ALLOWED
                : ObjectInputFilter.Status.REJECTED;
    }
    // Not a class, not size limited
    return ObjectInputFilter.Status.UNDECIDED;
}
 
Example 21
Source Project: perf-harness   Source File: AbstractJMSProvider.java    License: MIT License 5 votes vote down vote up
protected String createDurableConnectionId(String uniqueID) {
	String durableConnectionId;
	// Note proc_id is not set unless -id n passed on cmdline
	String proc_id = Config.parms.getString("id");
	if ( uniqueID!=null && proc_id!=null && proc_id.length()>0 ) {
		// This presumes that if you have given -id to this JVM
		// you have given a UNIQUE -id to ALL subscriber JVMs
		durableConnectionId = proc_id+"_"+uniqueID;
	} else {
		// If no -id then get a random ID ( UID() is crap at
		// this, but better than nothing ) 
		durableConnectionId = new UID().toString().replaceAll(":", "");
	}
	return durableConnectionId;
}
 
Example 22
/**
 * Generate a new random md5 hash.
 * @return a securely-generated random 16 byte sequence.
 */
public static byte [] generateMD5Bytes() {
  try {
    MessageDigest digester = MessageDigest.getInstance("MD5");
    long time = System.currentTimeMillis();
    digester.update((new UID() + "@" + time).getBytes());
    return digester.digest();
  } catch (NoSuchAlgorithmException e) {
    throw new RuntimeException(e);
  }
}
 
Example 23
Source Project: jdk8u_jdk   Source File: DGCAckHandler.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Causes the DGCAckHandler associated with the specified UID to
 * release its references.
 **/
public static void received(UID id) {
    DGCAckHandler h = idTable.remove(id);
    if (h != null) {
        h.release();
    }
}
 
Example 24
Source Project: jdk8u-jdk   Source File: DGCAckHandler.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Causes the DGCAckHandler associated with the specified UID to
 * release its references.
 **/
public static void received(UID id) {
    DGCAckHandler h = idTable.remove(id);
    if (h != null) {
        h.release();
    }
}
 
Example 25
/**
 * Constructs an marshal output stream using the underlying
 * stream associated with the connection, the parameter c.
 * @param c is the Connection object associated with the
 * ConnectionOutputStream object being constructed
 * @param resultStream indicates whether this stream is used
 * to marshal return results
 */
ConnectionOutputStream(Connection conn, boolean resultStream)
    throws IOException
{
    super(conn.getOutputStream());
    this.conn = conn;
    this.resultStream = resultStream;
    ackID = resultStream ? new UID() : null;
}
 
Example 26
/**
 * Constructs an marshal output stream using the underlying
 * stream associated with the connection, the parameter c.
 * @param c is the Connection object associated with the
 * ConnectionOutputStream object being constructed
 * @param resultStream indicates whether this stream is used
 * to marshal return results
 */
ConnectionOutputStream(Connection conn, boolean resultStream)
    throws IOException
{
    super(conn.getOutputStream());
    this.conn = conn;
    this.resultStream = resultStream;
    ackID = resultStream ? new UID() : null;
}
 
Example 27
Source Project: jdk8u-jdk   Source File: DGCImpl.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * ObjectInputFilter to filter DGC input objects.
 * The list of acceptable classes is very short and explicit.
 * The depth and array sizes are limited.
 *
 * @param filterInfo access to class, arrayLength, etc.
 * @return  {@link ObjectInputFilter.Status#ALLOWED} if allowed,
 *          {@link ObjectInputFilter.Status#REJECTED} if rejected,
 *          otherwise {@link ObjectInputFilter.Status#UNDECIDED}
 */
private static ObjectInputFilter.Status checkInput(ObjectInputFilter.FilterInfo filterInfo) {
    if (dgcFilter != null) {
        ObjectInputFilter.Status status = dgcFilter.checkInput(filterInfo);
        if (status != ObjectInputFilter.Status.UNDECIDED) {
            // The DGC filter can override the built-in white-list
            return status;
        }
    }

    if (filterInfo.depth() > DGC_MAX_DEPTH) {
        return ObjectInputFilter.Status.REJECTED;
    }
    Class<?> clazz = filterInfo.serialClass();
    if (clazz != null) {
        while (clazz.isArray()) {
            if (filterInfo.arrayLength() >= 0 && filterInfo.arrayLength() > DGC_MAX_ARRAY_SIZE) {
                return ObjectInputFilter.Status.REJECTED;
            }
            // Arrays are allowed depending on the component type
            clazz = clazz.getComponentType();
        }
        if (clazz.isPrimitive()) {
            // Arrays of primitives are allowed
            return ObjectInputFilter.Status.ALLOWED;
        }
        return (clazz == ObjID.class ||
                clazz == UID.class ||
                clazz == VMID.class ||
                clazz == Lease.class)
                ? ObjectInputFilter.Status.ALLOWED
                : ObjectInputFilter.Status.REJECTED;
    }
    // Not a class, not size limited
    return ObjectInputFilter.Status.UNDECIDED;
}
 
Example 28
Source Project: scipio-erp   Source File: MacroFormRenderer.java    License: Apache License 2.0 5 votes vote down vote up
private void executeMacro(Appendable writer, String macro) throws IOException { // SCIPIO: modified for exception
    try {
        Environment environment = getEnvironment(writer);
        Reader templateReader = new StringReader(macro);
        Template template = new Template(new UID().toString(), templateReader, FreeMarkerWorker.getDefaultOfbizConfig());
        templateReader.close();
        FreeMarkerWorker.includeTemplate(template, environment); // SCIPIO: use FreeMarkerWorker instead of Environment directly
    } catch (TemplateException | IOException e) {
        Debug.logError(e, "Error rendering screen thru ftl macro: " + macro, module);
        handleError(writer, e); // SCIPIO
    }
}
 
Example 29
/**
 * Causes the DGCAckHandler associated with the specified UID to
 * release its references.
 **/
public static void received(UID id) {
    DGCAckHandler h = idTable.remove(id);
    if (h != null) {
        h.release();
    }
}
 
Example 30
Source Project: perf-harness   Source File: DefaultMessageFactory.java    License: MIT License 5 votes vote down vote up
/**
 * Returns a correlation id constructed from a UID and the name of the targeted workerthread. 
 * @param worker
 * @throws UnknownHostException The local hostname is being used to identify this JVM but could not be looked up
 * (try using <code>-id</code> to avoid the requirement on hostname.
 */
protected String makeCorrelIdAsString(WorkerThread worker) throws UnknownHostException {
	String proc_id = Config.parms.getString("id");
	StringBuffer cid = new StringBuffer();
	if (proc_id != null && proc_id.length() > 0) {
		cid.append(proc_id);
	} else {
		cid.append( InetAddress.getLocalHost().toString() );	
	}
	
	cid.append(worker.getName());
	cid.append( new UID().toString() );
       Log.logger.log(Level.FINEST, "makeCorrelIDAsString: {0}", cid);
	return cid.toString();
}