Java 类javax.net.ssl.SSLSessionBindingEvent 实例源码

项目:wildfly-openssl    文件:OpenSSlSession.java   
@Override
public synchronized void putValue(String name, Object value) {
    if (name == null) {
        throw new IllegalArgumentException(Messages.MESSAGES.nameWasNull());
    }
    if (value == null) {
        throw new IllegalArgumentException(Messages.MESSAGES.valueWasNull());
    }
    Map<String, Object> values = this.values;
    if (values == null) {
        // Use size of 2 to keep the memory overhead small
        values = this.values = new HashMap<>(2);
    }
    Object old = values.put(name, value);
    if (value instanceof SSLSessionBindingListener) {
        ((SSLSessionBindingListener) value).valueBound(new SSLSessionBindingEvent(this, name));
    }
    notifyUnbound(old, name);
}
项目:netty4.0.27Learn    文件:OpenSslEngine.java   
@Override
public void putValue(String name, Object value) {
    ObjectUtil.checkNotNull(name, "name");
    ObjectUtil.checkNotNull(value, "value");

    Map<String, Object> values = this.values;
    if (values == null) {
        // Use size of 2 to keep the memory overhead small
        values = this.values = new HashMap<String, Object>(2);
    }
    Object old = values.put(name, value);
    if (value instanceof SSLSessionBindingListener) {
        ((SSLSessionBindingListener) value).valueBound(new SSLSessionBindingEvent(this, name));
    }
    notifyUnbound(old, name);
}
项目:In-the-Box-Fork    文件:SSLSessionBindingListenerTest.java   
/**
 * @throws IOException
 * @throws UnknownHostException
 * @throws InterruptedException
 * @tests javax.net.ssl.SSLSessionBindingListener#valueBound(SSLSessionBindingEvent event)
 */
@TestTargetNew(
    level = TestLevel.COMPLETE,
    notes = "",
    method = "valueBound",
    args = {SSLSessionBindingEvent.class}
)
public void test_valueBound() throws UnknownHostException, IOException,
        InterruptedException {
    SSLSocket sock = (SSLSocket) SSLSocketFactory.getDefault()
            .createSocket();
    SSLSession ss = sock.getSession();
    mySSLSessionBindingListener sbl = new mySSLSessionBindingListener();
    ss.putValue("test", sbl);
    assertTrue("valueBound was not called.", sbl.boundDone);
}
项目:In-the-Box-Fork    文件:SSLSessionBindingListenerTest.java   
/**
 * @throws IOException
 * @throws UnknownHostException
 * @tests javax.net.ssl.SSLSessionBindingListener#valueUnbound(SSLSessionBindingEvent event)
 */
@TestTargetNew(
    level = TestLevel.COMPLETE,
    notes = "",
    method = "valueUnbound",
    args = {SSLSessionBindingEvent.class}
)
public void test_valueUnbound() throws UnknownHostException, IOException {
    SSLSocket sock = (SSLSocket) SSLSocketFactory.getDefault()
            .createSocket();
    SSLSession ss = sock.getSession();
    mySSLSessionBindingListener sbl = new mySSLSessionBindingListener();
    ss.putValue("test", sbl);
    ss.removeValue("test");
    assertTrue("valueUnbound was not called.", sbl.unboundDone);
}
项目:freeVM    文件:SSLSessionImpl.java   
/**
 * @see javax.net.ssl.SSLSession.putValue(String name, Object value)
 */
public void putValue(String name, Object value) {
    if (name == null || value == null) {
        throw new IllegalArgumentException("Parameter is null");
    }
    Object old = values.put(name, AccessController.getContext(), value);
    if (value instanceof SSLSessionBindingListener) {
        ((SSLSessionBindingListener) value)
                .valueBound(new SSLSessionBindingEvent(this, name));
    }
    if (old != null && old instanceof SSLSessionBindingListener) {
        ((SSLSessionBindingListener) old)
                .valueUnbound(new SSLSessionBindingEvent(this, name));
    }

}
项目:conscrypt    文件:ExternalSession.java   
@Override
public void putValue(String name, Object value) {
  if (name == null || value == null) {
    throw new IllegalArgumentException("name == null || value == null");
  }
  Object old = values.put(name, value);
  if (value instanceof SSLSessionBindingListener) {
    ((SSLSessionBindingListener) value).valueBound(new SSLSessionBindingEvent(this, name));
  }
  if (old instanceof SSLSessionBindingListener) {
    ((SSLSessionBindingListener) old).valueUnbound(new SSLSessionBindingEvent(this, name));
  }

}
项目:conscrypt    文件:ExternalSession.java   
@Override
public void removeValue(String name) {
  if (name == null) {
    throw new IllegalArgumentException("name == null");
  }
  Object old = values.remove(name);
  if (old instanceof SSLSessionBindingListener) {
    SSLSessionBindingListener listener = (SSLSessionBindingListener) old;
    listener.valueUnbound(new SSLSessionBindingEvent(this, name));
  }
}
项目:javify    文件:Session.java   
public void putValue(String name, Object value)
{
  values.put(name, value);
  try
    {
      if (value instanceof SSLSessionBindingListener)
        ((SSLSessionBindingListener) value).valueBound
          (new SSLSessionBindingEvent(this, name));
    }
  catch (Exception x)
    {
    }
}
项目:javify    文件:Session.java   
public void removeValue(String name)
{
  Object value = values.remove(name);
  try
    {
      if (value instanceof SSLSessionBindingListener)
        ((SSLSessionBindingListener) value).valueUnbound
          (new SSLSessionBindingEvent(this, name));
    }
  catch (Exception x)
    {
    }
}
项目:jvm-stm    文件:Session.java   
public void putValue(String name, Object value)
{
  values.put(name, value);
  try
    {
      if (value instanceof SSLSessionBindingListener)
        ((SSLSessionBindingListener) value).valueBound
          (new SSLSessionBindingEvent(this, name));
    }
  catch (Exception x)
    {
    }
}
项目:jvm-stm    文件:Session.java   
public void removeValue(String name)
{
  Object value = values.remove(name);
  try
    {
      if (value instanceof SSLSessionBindingListener)
        ((SSLSessionBindingListener) value).valueUnbound
          (new SSLSessionBindingEvent(this, name));
    }
  catch (Exception x)
    {
    }   
}
项目:In-the-Box-Fork    文件:mySSLSession.java   
public void putValue(String s, Object obj) {
    if(s == null || obj == null)
        throw new IllegalArgumentException("arguments can not be null");
    Object obj1 = table.put(s, obj);
    if(obj1 instanceof SSLSessionBindingListener) {
        SSLSessionBindingEvent sslsessionbindingevent = new SSLSessionBindingEvent(this, s);
        ((SSLSessionBindingListener)obj1).valueUnbound(sslsessionbindingevent);
    }
    if(obj instanceof SSLSessionBindingListener) {
        SSLSessionBindingEvent sslsessionbindingevent1 = new SSLSessionBindingEvent(this, s);
        ((SSLSessionBindingListener)obj).valueBound(sslsessionbindingevent1);
    }
}
项目:In-the-Box-Fork    文件:mySSLSession.java   
public void removeValue(String s) {
    if(s == null)
        throw new IllegalArgumentException("argument can not be null");
    Object obj = table.remove(s);
    if(obj instanceof SSLSessionBindingListener) {
        SSLSessionBindingEvent sslsessionbindingevent = new SSLSessionBindingEvent(this, s);
        ((SSLSessionBindingListener)obj).valueUnbound(sslsessionbindingevent);
    }
}
项目:In-the-Box-Fork    文件:SSLSessionImpl.java   
public void putValue(String name, Object value) {
    if (name == null || value == null) {
        throw new IllegalArgumentException("Parameter is null");
    }
    Object old = values.put(new ValueKey(name), value);
    if (value instanceof SSLSessionBindingListener) {
        ((SSLSessionBindingListener) value).valueBound(new SSLSessionBindingEvent(this, name));
    }
    if (old instanceof SSLSessionBindingListener) {
        ((SSLSessionBindingListener) old).valueUnbound(new SSLSessionBindingEvent(this, name));
    }

}
项目:In-the-Box-Fork    文件:SSLSessionImpl.java   
public void removeValue(String name) {
    if (name == null) {
        throw new IllegalArgumentException("Parameter is null");
    }
    Object old = values.remove(new ValueKey(name));
    if (old instanceof SSLSessionBindingListener) {
        SSLSessionBindingListener listener = (SSLSessionBindingListener) old;
        listener.valueUnbound(new SSLSessionBindingEvent(this, name));
    }
}
项目:In-the-Box-Fork    文件:SSLSessionBindingEventTest.java   
/**
 * @tests javax.net.ssl.SSLSessionBindingEvent#getSession()
 */
@TestTargetNew(
    level = TestLevel.COMPLETE,
    notes = "",
    method = "getSession",
    args = {}
)
public void test_getSession() {
    SSLSession ses = new MySSLSession();
    SSLSessionBindingEvent event = new SSLSessionBindingEvent(ses, "test");
    assertEquals("Incorrect session", ses, event.getSession());
}
项目:cn1    文件:SSLSessionImpl.java   
public void putValue(String name, Object value) {
    if (name == null || value == null) {
        throw new IllegalArgumentException("Parameter is null");
    }
    Object old = values.put(new ValueKey(name), value);
    if (value instanceof SSLSessionBindingListener) {
        ((SSLSessionBindingListener) value).valueBound(new SSLSessionBindingEvent(this, name));
    }
    if (old != null && old instanceof SSLSessionBindingListener) {
        ((SSLSessionBindingListener) old).valueUnbound(new SSLSessionBindingEvent(this, name));
    }

}
项目:cn1    文件:SSLSessionBindingEventTest.java   
@Override
protected Object[] getData() {
    try {
        SSLContext cont = SSLContext.getInstance("TLS");
        cont.init(null, null, null);
        SSLSocket soc = (SSLSocket )cont.getSocketFactory().createSocket();
        return new Object[] { new SSLSessionBindingEvent(soc.getSession(), "someName")};
    } catch (Exception e) {
        fail("Can not create data: "+ e);
        return null;
    }
}
项目:cn1    文件:SSLSessionBindingEventTest.java   
public final void testSSLSessionBindingEvent() {
    SSLSession ses = new MySSLSession();
    SSLSessionBindingEvent event = new SSLSessionBindingEvent(ses, "test");

    assertEquals("test", event.getName());
    assertEquals(ses, event.getSession());
}
项目:JamVM-PH    文件:Session.java   
public void putValue(String name, Object value)
{
  values.put(name, value);
  try
    {
      if (value instanceof SSLSessionBindingListener)
        ((SSLSessionBindingListener) value).valueBound
          (new SSLSessionBindingEvent(this, name));
    }
  catch (Exception x)
    {
    }
}
项目:JamVM-PH    文件:Session.java   
public void removeValue(String name)
{
  Object value = values.remove(name);
  try
    {
      if (value instanceof SSLSessionBindingListener)
        ((SSLSessionBindingListener) value).valueUnbound
          (new SSLSessionBindingEvent(this, name));
    }
  catch (Exception x)
    {
    }   
}
项目:classpath    文件:Session.java   
public void putValue(String name, Object value)
{
  values.put(name, value);
  try
    {
      if (value instanceof SSLSessionBindingListener)
        ((SSLSessionBindingListener) value).valueBound
          (new SSLSessionBindingEvent(this, name));
    }
  catch (Exception x)
    {
    }
}
项目:classpath    文件:Session.java   
public void removeValue(String name)
{
  Object value = values.remove(name);
  try
    {
      if (value instanceof SSLSessionBindingListener)
        ((SSLSessionBindingListener) value).valueUnbound
          (new SSLSessionBindingEvent(this, name));
    }
  catch (Exception x)
    {
    }
}
项目:freeVM    文件:SSLSessionBindingEventTest.java   
protected Object[] getData() {
    try {
        SSLContext cont = SSLContext.getInstance("TLS");
        cont.init(null, null, null);
        SSLSocket soc = (SSLSocket )cont.getSocketFactory().createSocket();
        return new Object[] { new SSLSessionBindingEvent(soc.getSession(), "someName")};
    } catch (Exception e) {
        fail("Can not create data: "+ e);
        return null;
    }
}
项目:freeVM    文件:SSLSessionBindingEventTest.java   
public final void testSSLSessionBindingEvent() {
    SSLSession ses = new MySSLSession();
    SSLSessionBindingEvent event = new SSLSessionBindingEvent(ses, "test");
    if (!"test".equals(event.getName())) {
        fail("incorrect name");
    }
    if (!event.getSession().equals(ses)) {
        fail("incorrect session");
    }
}
项目:freeVM    文件:SSLSessionImpl.java   
public void putValue(String name, Object value) {
    if (name == null || value == null) {
        throw new IllegalArgumentException("Parameter is null");
    }
    Object old = values.put(new ValueKey(name), value);
    if (value instanceof SSLSessionBindingListener) {
        ((SSLSessionBindingListener) value).valueBound(new SSLSessionBindingEvent(this, name));
    }
    if (old != null && old instanceof SSLSessionBindingListener) {
        ((SSLSessionBindingListener) old).valueUnbound(new SSLSessionBindingEvent(this, name));
    }

}
项目:freeVM    文件:SSLSessionBindingEventTest.java   
@Override
protected Object[] getData() {
    try {
        SSLContext cont = SSLContext.getInstance("TLS");
        cont.init(null, null, null);
        SSLSocket soc = (SSLSocket )cont.getSocketFactory().createSocket();
        return new Object[] { new SSLSessionBindingEvent(soc.getSession(), "someName")};
    } catch (Exception e) {
        fail("Can not create data: "+ e);
        return null;
    }
}
项目:freeVM    文件:SSLSessionBindingEventTest.java   
public final void testSSLSessionBindingEvent() {
    SSLSession ses = new MySSLSession();
    SSLSessionBindingEvent event = new SSLSessionBindingEvent(ses, "test");

    assertEquals("test", event.getName());
    assertEquals(ses, event.getSession());
}
项目:openjdk-jdk10    文件:SSLSessionFinalizeTest.java   
@Override
public void valueBound(SSLSessionBindingEvent event) {
    System.out.printf(" valueBound: %s%n", event.getName());
}
项目:openjdk-jdk10    文件:SSLSessionFinalizeTest.java   
@Override
public void valueUnbound(SSLSessionBindingEvent event) {
    System.out.printf(" valueUnbound: %s%n", event.getName());
    unboundNotified++;
}
项目:conscrypt    文件:ActiveSession.java   
private void notifyUnbound(Object value, String name) {
    if (value instanceof SSLSessionBindingListener) {
        ((SSLSessionBindingListener) value)
                .valueUnbound(new SSLSessionBindingEvent(this, name));
    }
}
项目:wildfly-openssl    文件:OpenSSlSession.java   
private void notifyUnbound(Object value, String name) {
    if (value instanceof SSLSessionBindingListener) {
        ((SSLSessionBindingListener) value).valueUnbound(new SSLSessionBindingEvent(this, name));
    }
}
项目:netty4.0.27Learn    文件:OpenSslEngine.java   
private void notifyUnbound(Object value, String name) {
    if (value instanceof SSLSessionBindingListener) {
        ((SSLSessionBindingListener) value).valueUnbound(new SSLSessionBindingEvent(this, name));
    }
}
项目:In-the-Box-Fork    文件:SSLSessionBindingListenerTest.java   
public void valueBound(SSLSessionBindingEvent event) {
    if (event != null) boundDone = true;
}
项目:In-the-Box-Fork    文件:SSLSessionBindingListenerTest.java   
public void valueUnbound(SSLSessionBindingEvent event) {
    if (event != null) unboundDone = true;
}
项目:cn1    文件:SSLSessionBindingEventTest.java   
public void assertDeserialized(Serializable oref, Serializable otest) {
    SSLSessionBindingEvent ref = (SSLSessionBindingEvent) oref;
    SSLSessionBindingEvent test = (SSLSessionBindingEvent) otest;
    assertEquals(ref.getName(), test.getName());
}
项目:freeVM    文件:SSLSessionBindingEventTest.java   
public void assertDeserialized(Serializable oref, Serializable otest) {
    SSLSessionBindingEvent ref = (SSLSessionBindingEvent) oref;
    SSLSessionBindingEvent test = (SSLSessionBindingEvent) otest;
    assertEquals(ref.getName(), test.getName());
}
项目:freeVM    文件:SSLSessionBindingEventTest.java   
public void assertDeserialized(Serializable oref, Serializable otest) {
    SSLSessionBindingEvent ref = (SSLSessionBindingEvent) oref;
    SSLSessionBindingEvent test = (SSLSessionBindingEvent) otest;
    assertEquals(ref.getName(), test.getName());
}
项目:In-the-Box-Fork    文件:OpenSSLSessionImpl.java   
/**
 * A link (name) with the specified value object of the SSL session's
 * application layer data is created or replaced. If the new (or existing)
 * value object implements the <code>SSLSessionBindingListener</code>
 * interface, that object will be notified in due course. These links-to
 * -data bounds are monitored, as a matter of security, by the full
 * machinery of the <code>AccessController</code> class.
 *
 * @param name the name of the link (no null are
 *            accepted!)
 * @param value data object that shall be bound to
 *            name.
 * @throws <code>IllegalArgumentException</code> if one or both
 *             argument(s) is null.
 */
public void putValue(String name, Object value) {
    if (name == null || value == null) {
        throw new IllegalArgumentException("Parameter is null");
    }
    Object old = values.put(name, AccessController.getContext(), value);
    if (value instanceof SSLSessionBindingListener) {
        ((SSLSessionBindingListener) value)
                .valueBound(new SSLSessionBindingEvent(this, name));
    }
    if (old instanceof SSLSessionBindingListener) {
        ((SSLSessionBindingListener) old)
                .valueUnbound(new SSLSessionBindingEvent(this, name));
    }
}
项目:In-the-Box-Fork    文件:OpenSSLSessionImpl.java   
/**
 * Removes a link (name) with the specified value object of the SSL
 * session's application layer data.
 *
 * <p>If the value object implements the <code>SSLSessionBindingListener</code>
 * interface, the object will receive a <code>valueUnbound</code> notification.
 *
 * <p>These links-to -data bounds are
 * monitored, as a matter of security, by the full machinery of the
 * <code>AccessController</code> class.
 *
 * @param name the name of the link (no null are
 *            accepted!)
 * @throws <code>IllegalArgumentException</code> if the argument is null.
 */
public void removeValue(String name) {
    if (name == null) {
        throw new IllegalArgumentException("Parameter is null");
    }
    Object old = values.remove(name, AccessController.getContext());
    if (old instanceof SSLSessionBindingListener) {
        SSLSessionBindingListener listener = (SSLSessionBindingListener) old;
        listener.valueUnbound(new SSLSessionBindingEvent(this, name));
    }
}