Package org.nasutekds.server.api

Examples of org.nasutekds.server.api.ClientConnection


    NetworkGroup defaultNg = NetworkGroup.getDefaultNetworkGroup();

    // Create a new client connection, with anonymous authentication
    // It should match the default network group
    // as it has no bind information
    ClientConnection connection1 = new InternalClientConnection(DN.NULL_DN);
    NetworkGroup ng = NetworkGroup.findMatchingNetworkGroup(connection1);
    assertEquals(ng, defaultNg);

    // Use simple bind on this connection
    Entry userEntry = DirectoryServer.getEntry(
            DN.decode("cn=Directory Manager, cn=Root DNs, cn=config"));
    ByteString password = ByteString.valueOf("password");
    ClientConnection connection2 = new InternalClientConnection(
          new AuthenticationInfo(userEntry, userEntry.getDN(), password, true));
    ng = NetworkGroup.findMatchingNetworkGroup(connection2);
    if (match) {
      assertEquals(ng, networkGroup);
    } else {
      assertEquals(ng, defaultNg);
    }

    // Use SASL on this connection
    ClientConnection connection3 = new InternalClientConnection(
            new AuthenticationInfo(userEntry, "external", ByteString.valueOf(
                "cn=Directory Manager, cn=Root DNs, cn=config"), true));
    ng = NetworkGroup.findMatchingNetworkGroup(connection3);
    if (match) {
      assertEquals(ng, networkGroup);
View Full Code Here


    NetworkGroup defaultNg = NetworkGroup.getDefaultNetworkGroup();

    // Create a new client connection, with anonymous authentication
    // It should match the secured group as internal connections
    // are secured
    ClientConnection connection1 = new InternalClientConnection(DN.NULL_DN);
    NetworkGroup ng = NetworkGroup.findMatchingNetworkGroup(connection1);
    assertEquals(ng, networkGroup);

    // now change the criteria (security not mandatory)
    secCriteria = SecurityConnectionCriteria.SECURITY_NOT_REQUIRED;
View Full Code Here

  @Test(dataProvider = "testData")
  public void testMatches(boolean isSecure,
      SecurityConnectionCriteria criteria, boolean expectedResult)
      throws Exception
  {
    ClientConnection client =
        new MockClientConnection(12345, isSecure, DN.nullDN(),
            AllowedAuthMethod.ANONYMOUS);

    Assert.assertEquals(criteria.matches(client), expectedResult);
  }
View Full Code Here

  @Test(dataProvider = "testData")
  public void testWillMatchAfterBind(boolean isSecure,
      SecurityConnectionCriteria criteria, boolean expectedResult)
      throws Exception
  {
    ClientConnection client =
        new MockClientConnection(12345, false, DN.nullDN(),
            AllowedAuthMethod.ANONYMOUS);

    Assert.assertEquals(criteria.willMatchAfterBind(client,
        DN.nullDN(), AuthenticationType.SIMPLE, isSecure),
View Full Code Here

  public void testMatches(Collection<ConnectionCriteria> subCriteria,
      boolean expectedResult) throws Exception
  {
    ANDConnectionCriteria criteria =
        new ANDConnectionCriteria(subCriteria);
    ClientConnection connection =
        new InternalClientConnection(DN.NULL_DN);
    Assert.assertEquals(criteria.matches(connection), expectedResult);
  }
View Full Code Here

      Collection<ConnectionCriteria> subCriteria, boolean expectedResult)
      throws Exception
  {
    ANDConnectionCriteria criteria =
        new ANDConnectionCriteria(subCriteria);
    ClientConnection connection =
        new InternalClientConnection(DN.NULL_DN);
    Assert.assertEquals(criteria.willMatchAfterBind(connection,
        DN.NULL_DN, AuthenticationType.SIMPLE, false), expectedResult);
  }
View Full Code Here

    // Create a network group and store it in the client connection.
    // As the network group is empty, all searches should fail with a
    // no such object result code.
    String networkGroupID = "useNetworkGroupID";
    NetworkGroup networkGroup = new NetworkGroup(networkGroupID);
    ClientConnection clientConnection = searchOperation.getClientConnection();
    clientConnection.setNetworkGroup(networkGroup);
    searchOperation.run();
    assertEquals(searchOperation.getResultCode(), ResultCode.NO_SUCH_OBJECT);
   
    // Now register the o=test workflow and search again. The search
    // should succeed.
    networkGroup.registerWorkflow(workflowImpl);
    searchOperation.run();
    assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS);
   
    // Put back the internal network group in the client connection
    // and check that searches are still working.
    clientConnection.setNetworkGroup(NetworkGroup.getInternalNetworkGroup());
    searchOperation.run();
    assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS);
   
    // Back to the original configuration mode
    setModeAuto();
View Full Code Here

    {
      bindDN =
          DN.decode("cn=Directory Manager, cn=Root DNs, cn=config");
    }

    ClientConnection client =
        new MockClientConnection(12345, false, bindDN, clientAuthMethod);

    AuthMethodConnectionCriteria criteria =
        new AuthMethodConnectionCriteria(allowedAuthMethods);
    Assert.assertEquals(criteria.matches(client), expectedResult);
View Full Code Here

  public void testWillMatchAfterBind(
      AllowedAuthMethod clientAuthMethod,
      Collection<AllowedAuthMethod> allowedAuthMethods,
      boolean expectedResult) throws Exception
  {
    ClientConnection client =
        new MockClientConnection(12345, false, DN.nullDN(),
            AllowedAuthMethod.ANONYMOUS);

    AuthenticationType authType;
    DN bindDN;
View Full Code Here

   * {@inheritDoc}
   */
  @Override()
  public void processSASLBind(BindOperation bindOp)
  {
    ClientConnection clientConnection = bindOp.getClientConnection();
    if (clientConnection == null)
    {
      Message message = ERR_SASLGSSAPI_NO_CLIENT_CONNECTION.get();
      bindOp.setAuthFailureReason(message);
      bindOp.setResultCode(ResultCode.INVALID_CREDENTIALS);
      return;
    }
    ClientConnection clientConn = bindOp.getClientConnection();
    SASLContext saslContext = (SASLContext) clientConn.getSASLAuthStateInfo();
    if (saslContext == null) {
      try {
        //If the connection is secure already (i.e., TLS), then make the
        //receive buffers sizes match.
        if(clientConn.isSecure()) {
          HashMap<String, String>secProps =
                                  new HashMap<String,String>(saslProps);
          int maxBuf = clientConn.getAppBufferSize();
          secProps.put(Sasl.MAX_BUFFER, Integer.toString(maxBuf));
          saslContext = SASLContext.createSASLContext(secProps, serverFQDN,
                                  SASL_MECHANISM_GSSAPI, identityMapper);
        } else {
          saslContext = SASLContext.createSASLContext(saslProps, serverFQDN,
                                  SASL_MECHANISM_GSSAPI, identityMapper);
        }
      } catch (SaslException ex) {
        if (debugEnabled())
          TRACER.debugCaught(DebugLogLevel.ERROR, ex);
        Message msg;
        GSSException gex = (GSSException) ex.getCause();
        if(gex != null) {
          msg = ERR_SASL_CONTEXT_CREATE_ERROR.get(SASL_MECHANISM_GSSAPI,
              getGSSExceptionMessage(gex));
        } else {
          msg = ERR_SASL_CONTEXT_CREATE_ERROR.get(SASL_MECHANISM_GSSAPI,
              getExceptionMessage(ex));
        }
        clientConn.setSASLAuthStateInfo(null);
        bindOp.setAuthFailureReason(msg);
        bindOp.setResultCode(ResultCode.INVALID_CREDENTIALS);
        return;
      }
    }
View Full Code Here

TOP

Related Classes of org.nasutekds.server.api.ClientConnection

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.