• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java StartTlsResponse类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中javax.naming.ldap.StartTlsResponse的典型用法代码示例。如果您正苦于以下问题:Java StartTlsResponse类的具体用法?Java StartTlsResponse怎么用?Java StartTlsResponse使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



StartTlsResponse类属于javax.naming.ldap包,在下文中一共展示了StartTlsResponse类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: testAll

import javax.naming.ldap.StartTlsResponse; //导入依赖的package包/类
public void testAll() {
    assertEquals("1.3.6.1.4.1.1466.20037", StartTlsResponse.OID);

    StartTlsResponse str = new MockStartTlsResponse();

    assertEquals(StartTlsResponse.OID, str.getID());
    assertNull(str.getEncodedValue());
}
 
开发者ID:shannah,项目名称:cn1,代码行数:9,代码来源:StartTlsResponseTest.java


示例2: testCreateExtendedResponse004

import javax.naming.ldap.StartTlsResponse; //导入依赖的package包/类
/**
 * <p>Test method for 'javax.naming.ldap.StartTlsRequest.createExtendedResponse(String, byte[], int, int)'</p>
 * <p>Here we are testing if this method creates an extended response object that corresponds to the LDAP StartTLS extended request.
 * In this case we are testing the extended response with the argument ID="1.3.6.1.4.1.1466.20037" and the others arguments should be ignored.</p>
 * <p>Notice here that this package does not have a provider so an implementation does not exist, so this test must not fail with a provider 
 * and fail with no provider.</p>
 * <p>The expected result is a Tls response.</p>
 */
public void testCreateExtendedResponse004() throws Exception {
    StartTlsRequest str = new StartTlsRequest();
    String ID = "1.3.6.1.4.1.1466.20037";
    int t1 = 210, t2 = 650;
    byte[] t0 = ID.getBytes();

    StartTlsResponse x = (StartTlsResponse) str.createExtendedResponse(ID,
            t0, t1, t2);
    assertEquals(MockStartTlsResponse.class, x.getClass());
}
 
开发者ID:shannah,项目名称:cn1,代码行数:19,代码来源:StartTlsRequestTest.java


示例3: processContextAfterCreation

import javax.naming.ldap.StartTlsResponse; //导入依赖的package包/类
public final DirContext processContextAfterCreation(DirContext ctx, String userDn, String password)
		throws NamingException {

	if (ctx instanceof LdapContext) {
		final LdapContext ldapCtx = (LdapContext) ctx;
		final StartTlsResponse tlsResponse = (StartTlsResponse) ldapCtx.extendedOperation(new StartTlsRequest());
		try {
			if (hostnameVerifier != null) {
				tlsResponse.setHostnameVerifier(hostnameVerifier);
			}
			tlsResponse.negotiate(sslSocketFactory); // If null, the default SSL socket factory is used
			applyAuthentication(ldapCtx, userDn, password);

			if (shutdownTlsGracefully) {
				// Wrap the target context in a proxy to intercept any calls
				// to 'close', so that we can shut down the TLS connection
				// gracefully first.
				return (DirContext) Proxy.newProxyInstance(DirContextProxy.class.getClassLoader(), new Class<?>[] {
						LdapContext.class, DirContextProxy.class }, new TlsAwareDirContextProxy(ldapCtx,
						tlsResponse));
			}
			else {
				return ctx;
			}
		}
		catch (IOException e) {
			LdapUtils.closeContext(ctx);
			throw new UncategorizedLdapException("Failed to negotiate TLS session", e);
		}
	}
	else {
		throw new IllegalArgumentException(
				"Processed Context must be an LDAPv3 context, i.e. an LdapContext implementation");
	}

}
 
开发者ID:spring-projects,项目名称:spring-ldap,代码行数:37,代码来源:AbstractTlsDirContextAuthenticationStrategy.java


示例4: setup

import javax.naming.ldap.StartTlsResponse; //导入依赖的package包/类
@Before
public void setup() throws NamingException {
  mockLogChannelInterface = mock( LogChannelInterface.class );
  mockVariableSpace = mock( VariableSpace.class );
  mockLdapMeta = mock( LdapMeta.class );
  mockInitialLdapContext = mock( InitialLdapContext.class );
  mockStartTlsResponse = mock( StartTlsResponse.class );
  when( mockInitialLdapContext.extendedOperation( any( StartTlsRequest.class ) ) ).thenReturn(
    mockStartTlsResponse );
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:11,代码来源:LdapTlsProtocolIT.java


示例5: getTlsResponse

import javax.naming.ldap.StartTlsResponse; //导入依赖的package包/类
public StartTlsResponse getTlsResponse() {
    return tlsResp;
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:4,代码来源:JiveInitialLdapContext.java


示例6: setTlsResponse

import javax.naming.ldap.StartTlsResponse; //导入依赖的package包/类
public void setTlsResponse(StartTlsResponse tlsResp) {
    this.tlsResp = tlsResp;
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:4,代码来源:JiveInitialLdapContext.java


示例7: getTlsResponse

import javax.naming.ldap.StartTlsResponse; //导入依赖的package包/类
public StartTlsResponse getTlsResponse() {
	return tlsResp;
}
 
开发者ID:coodeer,项目名称:g3server,代码行数:4,代码来源:JiveInitialLdapContext.java


示例8: setTlsResponse

import javax.naming.ldap.StartTlsResponse; //导入依赖的package包/类
public void setTlsResponse(StartTlsResponse tlsResp) {
	this.tlsResp = tlsResp;
}
 
开发者ID:coodeer,项目名称:g3server,代码行数:4,代码来源:JiveInitialLdapContext.java


示例9: connect

import javax.naming.ldap.StartTlsResponse; //导入依赖的package包/类
/**
 *  Connect to LDAP server
 *  @param username : username
 *  @param password : password
 *  @throws KettleException
 */
public void connect(String username, String password) throws KettleException {

  getEnv().put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
  getEnv().put("java.naming.ldap.derefAliases", getDerefAliases());
  getEnv().put(Context.REFERRAL, getReferral());

  if (getHostName().indexOf("ldap://") >= 0)
    getEnv().put(Context.PROVIDER_URL, getHostName() + ":" + getPort());
  else
    getEnv().put(Context.PROVIDER_URL, "ldap://" + getHostName() + ":" + getPort());

  if (getProtocol() == PROTOCOL_LDAP_SSL) {
    getEnv().put(javax.naming.Context.SECURITY_PROTOCOL, "ssl");
    
    // setup factory for SSL; for TLS, we specify this factory in the StartTlsResponse.negotiate(factory) call
    getEnv().put("java.naming.ldap.factory.socket",
        "org.pentaho.di.trans.steps.ldapinput.store.CustomdSocketFactory");
  }

  if (getProtocol() != PROTOCOL_LDAP) { // if SSL or TLS
      if (isTrustAllCertificates()) {
        CustomSocketFactory.configure();
      } else {
        CustomSocketFactory.configure(getTrustStorePath(), getTrustStorePassword());
      }
  }

  if (!Const.isEmpty(username)) {
    this.username = username;
    getEnv().put(Context.SECURITY_PRINCIPAL, username);
    getEnv().put(Context.SECURITY_CREDENTIALS, password);
    getEnv().put(Context.SECURITY_AUTHENTICATION, "simple");
  } else {
    getEnv().put(Context.SECURITY_AUTHENTICATION, "none");
  }

  try {
    /* Establish LDAP association */
    this.ctx = new InitialLdapContext(getEnv(), null);
    if (getInitialContext() == null) {
      throw new KettleException(BaseMessages.getString(PKG, "LDAPInput.Error.UnableToConnectToServer"));
    }

    if (getProtocol() == PROTOCOL_LDAP_TLS) {
      /* Requesting to start TLS on an LDAP association */
      StartTlsRequest tlsRequest = new StartTlsRequest();
      this.tls = (StartTlsResponse) getInitialContext().extendedOperation(tlsRequest);
      /* Starting TLS */
      this.tls.negotiate((SSLSocketFactory) CustomSocketFactory.getDefault());
    }

    if (log.isBasic())
      log.logBasic(BaseMessages.getString(PKG, "LDAPInput.Log.ConnectedToServer", getHostName(),
          Const.NVL(getUserName(), "")));
    if (log.isDetailed())
      log.logDetailed(BaseMessages.getString(PKG, "LDAPInput.ClassUsed.Message", getInitialContext().getClass()
          .getName()));

  } catch (Exception e) {
    throw new KettleException(BaseMessages.getString(PKG, "LDAPinput.Exception.ErrorConnecting", e.getMessage()), e);
  }
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:69,代码来源:LDAPConnection.java


示例10: TlsAwareDirContextProxy

import javax.naming.ldap.StartTlsResponse; //导入依赖的package包/类
public TlsAwareDirContextProxy(LdapContext target, StartTlsResponse tlsResponse) {
	this.target = target;
	this.tlsResponse = tlsResponse;
}
 
开发者ID:spring-projects,项目名称:spring-ldap,代码行数:5,代码来源:AbstractTlsDirContextAuthenticationStrategy.java


示例11: testExtendedOperation002

import javax.naming.ldap.StartTlsResponse; //导入依赖的package包/类
/**
 * <p>
 * Test method for
 * 'javax.naming.ldap.InitialLdapContext.extendedOperation(ExtendedRequest)'
 * </p>
 * <p>
 * Here we are testing if this method correctly executes the given
 * operation. Here we send a non-null ExtendedRequest.
 * </p>
 * <p>
 * The expected result is an ExtendedResponse.
 * </p>
 */
public void testExtendedOperation002() throws Exception {
    System.setProperty(Context.INITIAL_CONTEXT_FACTORY,
                    "org.apache.harmony.jndi.tests.javax.naming.spi.mock.ldap.MockContextFactory");
    InitialLdapContext x = new InitialLdapContext();
    StartTlsResponse f = (StartTlsResponse)x.extendedOperation(new StartTlsRequest());
    assertNotNull(f);
    x.close();
}
 
开发者ID:shannah,项目名称:cn1,代码行数:22,代码来源:TestInitialLdapContext.java


示例12: testExtendedOperation002

import javax.naming.ldap.StartTlsResponse; //导入依赖的package包/类
/**
 * <p>
 * Test method for
 * 'javax.naming.ldap.InitialLdapContext.extendedOperation(ExtendedRequest)'
 * </p>
 * <p>
 * Here we are testing if this method performs an extended operation. Here
 * we send a not null extended operation.
 * </p>
 * <p>
 * The expected result is an Extended Response.
 * </p>
 */
public void testExtendedOperation002() throws Exception {
    System.setProperty(Context.INITIAL_CONTEXT_FACTORY,
                    "org.apache.harmony.jndi.tests.javax.naming.spi.mock.ldap.MockContextFactory");
    InitialLdapContext x = new InitialLdapContext();
    StartTlsResponse f = (StartTlsResponse)x.extendedOperation(new StartTlsRequest());
    assertNotNull(f);
    x.close();
}
 
开发者ID:freeVM,项目名称:freeVM,代码行数:22,代码来源:TestInitialLdapContext.java



注:本文中的javax.naming.ldap.StartTlsResponse类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java TTest类代码示例发布时间:2022-05-21
下一篇:
Java MenuBarPeer类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap