当前位置: 首页>>代码示例>>Java>>正文


Java RealmCallback类代码示例

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


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

示例1: handle

import javax.security.sasl.RealmCallback; //导入依赖的package包/类
@Override
public void handle(Callback[] callbacks) throws UnsupportedCallbackException {
    for (Callback callback : callbacks) {
        if (callback instanceof NameCallback) {
            NameCallback nc = (NameCallback) callback;
            nc.setName(nc.getDefaultName());
        } else if (callback instanceof PasswordCallback) {
            String errorMessage = "Could not login: the client is being asked for a password, but the Kafka" +
                         " client code does not currently support obtaining a password from the user.";
            throw new UnsupportedCallbackException(callback, errorMessage);
        } else if (callback instanceof RealmCallback) {
            RealmCallback rc = (RealmCallback) callback;
            rc.setText(rc.getDefaultText());
        } else {
            throw new UnsupportedCallbackException(callback, "Unrecognized SASL Login callback");
        }
    }
}
 
开发者ID:YMCoding,项目名称:kafka-0.11.0.0-src-with-comment,代码行数:19,代码来源:AbstractLogin.java

示例2: handle

import javax.security.sasl.RealmCallback; //导入依赖的package包/类
@Override
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
    for (Callback callback : callbacks) {
        if (callback instanceof NameCallback) {
            NameCallback nameCallback = (NameCallback) callback;
            nameCallback.setName(nameCallback.getDefaultName());
        } else if (callback instanceof PasswordCallback) {
            PasswordCallback passwordCallback = (PasswordCallback) callback;
            passwordCallback.setPassword(TestJaasConfig.PASSWORD.toCharArray());
        } else if (callback instanceof RealmCallback) {
            RealmCallback realmCallback = (RealmCallback) callback;
            realmCallback.setText(realmCallback.getDefaultText());
        } else if (callback instanceof AuthorizeCallback) {
            AuthorizeCallback authCallback = (AuthorizeCallback) callback;
            if (TestJaasConfig.USERNAME.equals(authCallback.getAuthenticationID())) {
                authCallback.setAuthorized(true);
                authCallback.setAuthorizedID(authCallback.getAuthenticationID());
            }
        }
    }
}
 
开发者ID:YMCoding,项目名称:kafka-0.11.0.0-src-with-comment,代码行数:22,代码来源:TestDigestLoginModule.java

示例3: testSaslClientCallbackHandler

import javax.security.sasl.RealmCallback; //导入依赖的package包/类
@Test
public void testSaslClientCallbackHandler() throws UnsupportedCallbackException {
  final Token<? extends TokenIdentifier> token = createTokenMock();
  when(token.getIdentifier()).thenReturn(DEFAULT_USER_NAME.getBytes());
  when(token.getPassword()).thenReturn(DEFAULT_USER_PASSWORD.getBytes());

  final NameCallback nameCallback = mock(NameCallback.class);
  final PasswordCallback passwordCallback = mock(PasswordCallback.class);
  final RealmCallback realmCallback = mock(RealmCallback.class);
  final RealmChoiceCallback realmChoiceCallback = mock(RealmChoiceCallback.class);

  Callback[] callbackArray = {nameCallback, passwordCallback,
      realmCallback, realmChoiceCallback};
  final SaslClientCallbackHandler saslClCallbackHandler = new SaslClientCallbackHandler(token);
  saslClCallbackHandler.handle(callbackArray);
  verify(nameCallback).setName(anyString());
  verify(realmCallback).setText(anyString());
  verify(passwordCallback).setPassword(any(char[].class));
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:20,代码来源:TestHBaseSaslRpcClient.java

示例4: handle

import javax.security.sasl.RealmCallback; //导入依赖的package包/类
@Override
public void handle(Callback[] callbacks) throws UnsupportedCallbackException {
    for (Callback callback : callbacks) {
        if (callback instanceof NameCallback) {
            NameCallback nc = (NameCallback) callback;
            nc.setName(nc.getDefaultName());
        } else if (callback instanceof PasswordCallback) {
            String errorMessage = "Could not login: the client is being asked for a password, but this " +
                    " module does not currently support obtaining a password from the user.";
            throw new UnsupportedCallbackException(callback, errorMessage);
        } else if (callback instanceof RealmCallback) {
            RealmCallback rc = (RealmCallback) callback;
            rc.setText(rc.getDefaultText());
        } else {
            throw new UnsupportedCallbackException(callback, "Unrecognized Login callback");
        }
    }
}
 
开发者ID:hortonworks,项目名称:registry,代码行数:19,代码来源:AbstractLogin.java

示例5: processCallback

import javax.security.sasl.RealmCallback; //导入依赖的package包/类
protected void processCallback(Callback callback) throws IOException, UnsupportedCallbackException
{
  if (callback instanceof NameCallback) {
    NameCallback namecb = (NameCallback)callback;
    namecb.setName(context.getValue(SecurityContext.USER_NAME));
  } else if (callback instanceof PasswordCallback) {
    PasswordCallback passcb = (PasswordCallback)callback;
    passcb.setPassword(context.getValue(SecurityContext.PASSWORD));
  } else if (callback instanceof RealmCallback) {
    RealmCallback realmcb = (RealmCallback)callback;
    realmcb.setText(context.getValue(SecurityContext.REALM));
  } else if (callback instanceof TextOutputCallback) {
    TextOutputCallback textcb = (TextOutputCallback)callback;
    if (textcb.getMessageType() == TextOutputCallback.INFORMATION) {
      logger.info(textcb.getMessage());
    } else if (textcb.getMessageType() == TextOutputCallback.WARNING) {
      logger.warn(textcb.getMessage());
    } else if (textcb.getMessageType() == TextOutputCallback.ERROR) {
      logger.error(textcb.getMessage());
    } else {
      logger.debug("Auth message type {}, message {}", textcb.getMessageType(), textcb.getMessage());
    }
  } else {
    throw new UnsupportedCallbackException(callback);
  }
}
 
开发者ID:apache,项目名称:apex-core,代码行数:27,代码来源:DefaultCallbackHandler.java

示例6: handle

import javax.security.sasl.RealmCallback; //导入依赖的package包/类
@Override
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
    for(Callback callback : callbacks) {
        if (callback instanceof NameCallback) {
            NameCallback nameCallback = (NameCallback)callback;
            nameCallback.setName("user");
        } else if (callback instanceof PasswordCallback) {
            PasswordCallback passwordCallback = (PasswordCallback)callback;
            passwordCallback.setPassword(password.toCharArray());
        } else if (callback instanceof AuthorizeCallback) {
            AuthorizeCallback authorizeCallback = (AuthorizeCallback)callback;
            authorizeCallback.setAuthorized(authorizeCallback.getAuthenticationID().equals(authorizeCallback.getAuthorizationID()));
        } else if (callback instanceof RealmCallback) {
            RealmCallback realmCallback = (RealmCallback) callback;
            realmCallback.setText(REALM);
        } else {
            throw new UnsupportedCallbackException(callback);
        }
    }
}
 
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:21,代码来源:SASLTest.java

示例7: handle

import javax.security.sasl.RealmCallback; //导入依赖的package包/类
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
    for (Callback current : callbacks) {
        if (current instanceof NameCallback) {
            NameCallback ncb = (NameCallback) current;
            ncb.setName(args[0]);
        } else if (current instanceof PasswordCallback) {
            PasswordCallback pcb = (PasswordCallback) current;
            pcb.setPassword(args[1].toCharArray());
        } else if (current instanceof RealmCallback) {
            RealmCallback rcb = (RealmCallback) current;
            rcb.setText(rcb.getDefaultText());
        } else {
            throw new UnsupportedCallbackException(current);
        }
    }
}
 
开发者ID:wildfly-swarm,项目名称:wildfly-config-api,代码行数:17,代码来源:AuthCallback.java

示例8: handle

import javax.security.sasl.RealmCallback; //导入依赖的package包/类
/**
 * 
 */
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
    for (int i = 0; i < callbacks.length; i++) {
        if (callbacks[i] instanceof NameCallback) {
            NameCallback ncb = (NameCallback)callbacks[i];
            ncb.setName(authenticationId);
        } else if(callbacks[i] instanceof PasswordCallback) {
            PasswordCallback pcb = (PasswordCallback)callbacks[i];
            pcb.setPassword(password.toCharArray());
        } else if(callbacks[i] instanceof RealmCallback) {
            RealmCallback rcb = (RealmCallback)callbacks[i];
            rcb.setText(hostname);
        } else if(callbacks[i] instanceof RealmChoiceCallback){
            //unused
            //RealmChoiceCallback rccb = (RealmChoiceCallback)callbacks[i];
        } else {
           throw new UnsupportedCallbackException(callbacks[i]);
        }
     }
}
 
开发者ID:ice-coffee,项目名称:EIM,代码行数:23,代码来源:SASLMechanism.java

示例9: handle

import javax.security.sasl.RealmCallback; //导入依赖的package包/类
@Override
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
    for (Callback current : callbacks) {
        if (current instanceof NameCallback) {
            NameCallback ncb = (NameCallback) current;
            ncb.setName(this.userName);
        } else if (current instanceof PasswordCallback) {
            PasswordCallback pcb = (PasswordCallback) current;
            pcb.setPassword(this.password.toCharArray());
        } else if (current instanceof RealmCallback) {
            RealmCallback rcb = (RealmCallback) current;
            rcb.setText(rcb.getDefaultText());
        } else {
            throw new UnsupportedCallbackException(current);
        }
    }

}
 
开发者ID:wildfly-swarm-archive,项目名称:ARCHIVE-wildfly-swarm,代码行数:19,代码来源:AuthCallbackHandler.java

示例10: handle

import javax.security.sasl.RealmCallback; //导入依赖的package包/类
@Override
public void handle(Callback[] callbacks)
    throws IOException, UnsupportedCallbackException {
  for (Callback cb : callbacks) {
    if (cb instanceof RealmChoiceCallback) {
      continue; // Ignore.
    } else if (cb instanceof NameCallback) {
      ((NameCallback)cb).setName(token_.identifier);
    } else if (cb instanceof PasswordCallback) {
      PasswordCallback pcb = ((PasswordCallback)cb);
      if (token_.password == null) {
        pcb.setPassword(null);
      } else {
        pcb.setPassword(token_.password.toCharArray());
      }
    } else if (cb instanceof RealmCallback) {
      RealmCallback rcb = (RealmCallback)cb;
      rcb.setText(rcb.getDefaultText());
    } else {
      throw new UnsupportedCallbackException(cb, "Unexpected DIGEST-MD5 callback");
    }
  }
}
 
开发者ID:cloudera,项目名称:RecordServiceClient,代码行数:24,代码来源:ThriftUtils.java

示例11: getClient

import javax.security.sasl.RealmCallback; //导入依赖的package包/类
public ModelControllerClient getClient() throws Exception {
    return ModelControllerClient.Factory.create(
            InetAddress.getByName(host),
            port,
            new CallbackHandler() {
                public void handle(Callback[] callbacks)
                        throws IOException, UnsupportedCallbackException {
                    for (Callback current : callbacks) {
                        if (current instanceof NameCallback) {
                            NameCallback ncb = (NameCallback) current;
                            ncb.setName(adminUser);
                        } else if (current instanceof PasswordCallback) {
                            PasswordCallback pcb = (PasswordCallback) current;
                            pcb.setPassword(adminPassword.toCharArray());
                        } else if (current instanceof RealmCallback) {
                            RealmCallback rcb = (RealmCallback) current;
                            rcb.setText(rcb.getDefaultText());
                        } else {
                            throw new UnsupportedCallbackException(current);
                        }
                    }
                }
            });
}
 
开发者ID:kiegroup,项目名称:appformer,代码行数:25,代码来源:BaseWildflyCLIManager.java

示例12: handle

import javax.security.sasl.RealmCallback; //导入依赖的package包/类
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
    for (Callback current : callbacks) {
        if (current instanceof NameCallback) {
            NameCallback ncb = (NameCallback) current;
            ncb.setName(username);
        } else if (current instanceof PasswordCallback) {
            PasswordCallback pcb = (PasswordCallback) current;
            pcb.setPassword(password.toCharArray());
        } else if (current instanceof RealmCallback) {
            RealmCallback rcb = (RealmCallback) current;
            rcb.setText(rcb.getDefaultText());
        } else {
            throw new UnsupportedCallbackException(current);
        }
    }
}
 
开发者ID:fabric8io,项目名称:jube,代码行数:17,代码来源:SimpleCallbackHandler.java

示例13: testSaslClientCallbackHandler

import javax.security.sasl.RealmCallback; //导入依赖的package包/类
@Test
public void testSaslClientCallbackHandler() throws UnsupportedCallbackException {
  final Token<? extends TokenIdentifier> token = createTokenMock();
  when(token.getIdentifier()).thenReturn(Bytes.toBytes(DEFAULT_USER_NAME));
  when(token.getPassword()).thenReturn(Bytes.toBytes(DEFAULT_USER_PASSWORD));

  final NameCallback nameCallback = mock(NameCallback.class);
  final PasswordCallback passwordCallback = mock(PasswordCallback.class);
  final RealmCallback realmCallback = mock(RealmCallback.class);
  final RealmChoiceCallback realmChoiceCallback = mock(RealmChoiceCallback.class);

  Callback[] callbackArray = {nameCallback, passwordCallback, realmCallback, realmChoiceCallback};
  final SaslClientCallbackHandler saslClCallbackHandler = new SaslClientCallbackHandler(token);
  saslClCallbackHandler.handle(callbackArray);
  verify(nameCallback).setName(anyString());
  verify(realmCallback).setText(any());
  verify(passwordCallback).setPassword(any());
}
 
开发者ID:apache,项目名称:hbase,代码行数:19,代码来源:TestHBaseSaslRpcClient.java

示例14: handle

import javax.security.sasl.RealmCallback; //导入依赖的package包/类
@Override
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
    for (Callback callback : callbacks) {
        if (callback instanceof AuthorizeCallback) {
            AuthorizeCallback authorizeCallback = (AuthorizeCallback) callback;
            String authenticationId = authorizeCallback.getAuthenticationID();
            String authorizationId = authorizeCallback.getAuthorizationID();
            authorizeCallback.setAuthorized(authenticationId.equals(authorizationId));
        } else if (callback instanceof NameCallback) {
            ((NameCallback) callback).setName("glowroot");
        } else if (callback instanceof PasswordCallback) {
            ((PasswordCallback) callback).setPassword(password);
        } else if (callback instanceof RealmCallback) {
            ((RealmCallback) callback).setText("glowroot");
        }
    }
}
 
开发者ID:glowroot,项目名称:glowroot,代码行数:18,代码来源:SaslCallbackHandler.java

示例15: serverCallbackHandler

import javax.security.sasl.RealmCallback; //导入依赖的package包/类
private CallbackHandler serverCallbackHandler(String username, String realm, String password) {
    return callbacks -> {
        for (Callback callback : callbacks) {
            if (callback instanceof NameCallback) {
                Assert.assertEquals(username, ((NameCallback) callback).getDefaultName());
            } else if (callback instanceof RealmCallback) {
                Assert.assertEquals(realm, ((RealmCallback) callback).getDefaultText());
            } else if (callback instanceof PasswordCallback) {
                ((PasswordCallback) callback).setPassword(password.toCharArray());
            } else if (callback instanceof AuthorizeCallback) {
                ((AuthorizeCallback) callback).setAuthorized(((AuthorizeCallback) callback).getAuthorizationID().equals(((AuthorizeCallback) callback).getAuthenticationID()));
            } else {
                throw new UnsupportedCallbackException(callback);
            }
        }
    };
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:18,代码来源:SaslTestCase.java


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