本文整理汇总了Java中org.apache.commons.lang3.tuple.Pair.getKey方法的典型用法代码示例。如果您正苦于以下问题:Java Pair.getKey方法的具体用法?Java Pair.getKey怎么用?Java Pair.getKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.lang3.tuple.Pair
的用法示例。
在下文中一共展示了Pair.getKey方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildSamlResponse
import org.apache.commons.lang3.tuple.Pair; //导入方法依赖的package包/类
/**
* Build saml response.
*
* @param response the response
* @param request the request
* @param authenticationContext the authentication context
* @param casAssertion the cas assertion
* @param binding the binding
*/
protected void buildSamlResponse(final HttpServletResponse response,
final HttpServletRequest request,
final Pair<AuthnRequest, MessageContext> authenticationContext,
final Assertion casAssertion,
final String binding) {
final String issuer = SamlIdPUtils.getIssuerFromSamlRequest(authenticationContext.getKey());
LOGGER.debug("Located issuer [{}] from authentication context", issuer);
final SamlRegisteredService registeredService = verifySamlRegisteredService(issuer);
LOGGER.debug("Located SAML metadata for [{}]", registeredService);
final Optional<SamlRegisteredServiceServiceProviderMetadataFacade> adaptor =
getSamlMetadataFacadeFor(registeredService, authenticationContext.getKey());
if (!adaptor.isPresent()) {
throw new UnauthorizedServiceException(UnauthorizedServiceException.CODE_UNAUTHZ_SERVICE, "Cannot find metadata linked to " + issuer);
}
LOGGER.debug("Preparing SAML response for [{}]", adaptor.get().getEntityId());
final SamlRegisteredServiceServiceProviderMetadataFacade facade = adaptor.get();
final AuthnRequest authnRequest = authenticationContext.getKey();
this.responseBuilder.build(authnRequest, request, response,
casAssertion, registeredService, facade, binding);
LOGGER.info("Built the SAML response for [{}]", facade.getEntityId());
}
示例2: update
import org.apache.commons.lang3.tuple.Pair; //导入方法依赖的package包/类
public void update() {
entityItem.age += 4;
BlockPos lastPos = pos;
pos = drone.getTargetedBlock();
if (pos != null) {
if (lastPos == null) {
oldPos = pos;
} else if (!pos.equals(lastPos)) {
progress = 0;
oldPos = lastPos;
}
} else {
oldPos = null;
}
progress = Math.min((float) Math.PI, progress + 0.1F);
Iterator<Pair<RenderCoordWireframe, Integer>> iterator = blackListWireframes.iterator();
while (iterator.hasNext()) {
Pair<RenderCoordWireframe, Integer> wireframe = iterator.next();
wireframe.getKey().ticksExisted++;
wireframe.setValue(wireframe.getValue() - 1);
if (wireframe.getValue() <= 0) {
iterator.remove();
}
}
}
示例3: HeatFrameCoolingRecipe
import org.apache.commons.lang3.tuple.Pair; //导入方法依赖的package包/类
public HeatFrameCoolingRecipe(Object input, ItemStack output) {
if (input == null) throw new NullPointerException("Input can't be null!");
if (output == null) throw new NullPointerException("Output can't be null!");
if (!(input instanceof ItemStack) && !(input instanceof Pair))
throw new IllegalArgumentException("Input needs to be of type ItemStack or org.apache.commons.lang3.tuple.Pair<String, Integer>. Violating object: " + input);
if (input instanceof Pair) {
Pair pair = (Pair) input;
if (!(pair.getKey() instanceof String))
throw new IllegalArgumentException("Pair key needs to be a String (ore dict entry)");
if (!(pair.getValue() instanceof Integer))
throw new IllegalArgumentException("Pair value needs to be an Integer (amount)");
}
this.input = input;
this.output = output;
}
示例4: PressureChamberRecipe
import org.apache.commons.lang3.tuple.Pair; //导入方法依赖的package包/类
public PressureChamberRecipe(Object[] input, float pressureRequired, ItemStack[] output) {
for (Object o : input) {
if (!(o instanceof ItemStack) && !(o instanceof Pair))
throw new IllegalArgumentException("Input objects need to be of type ItemStack or (Apache's) Pair<String, Integer>. Violating object: " + o);
if (o instanceof Pair) {
Pair pair = (Pair) o;
if (!(pair.getKey() instanceof String))
throw new IllegalArgumentException("Pair key needs to be a String (ore dict entry)");
if (!(pair.getValue() instanceof Integer))
throw new IllegalArgumentException("Value key needs to be an Integer (amount)");
}
}
this.input = input;
this.output = NonNullList.from(ItemStack.EMPTY, output);
pressure = pressureRequired;
}
示例5: doAuthentication
import org.apache.commons.lang3.tuple.Pair; //导入方法依赖的package包/类
@Override
protected HandlerResult doAuthentication(final Credential credential) throws GeneralSecurityException, PreventedException {
try {
final RadiusTokenCredential radiusCredential = (RadiusTokenCredential) credential;
final String password = radiusCredential.getToken();
final RequestContext context = RequestContextHolder.getRequestContext();
final String username = WebUtils.getAuthentication(context).getPrincipal().getId();
final Pair<Boolean, Optional<Map<String, Object>>> result =
RadiusUtils.authenticate(username, password, this.servers,
this.failoverOnAuthenticationFailure, this.failoverOnException);
if (result.getKey()) {
return createHandlerResult(credential,
this.principalFactory.createPrincipal(username, result.getValue().get()),
new ArrayList<>());
}
throw new FailedLoginException("Radius authentication failed for user " + username);
} catch (final Exception e) {
throw new FailedLoginException("Radius authentication failed " + e.getMessage());
}
}
示例6: requestJoin
import org.apache.commons.lang3.tuple.Pair; //导入方法依赖的package包/类
@Override
public JoinResponse requestJoin(UUID player, JoinResponse response)
{
if (api.getGame() != null)
{
Game game = api.getGame();
Pair<Boolean, String> gameResponse = game.canJoinGame(player, false);
if (gameResponse.getKey())
{
response.allow();
}
else
{
response.disallow(gameResponse.getValue());
return response;
}
response = checkState(game, response, player);
}
return response;
}
示例7: validateRequestAndBuildCasAssertion
import org.apache.commons.lang3.tuple.Pair; //导入方法依赖的package包/类
private Assertion validateRequestAndBuildCasAssertion(final HttpServletResponse response,
final HttpServletRequest request,
final Pair<AuthnRequest, MessageContext> pair) throws Exception {
final AuthnRequest authnRequest = pair.getKey();
final String ticket = CommonUtils.safeGetParameter(request, CasProtocolConstants.PARAMETER_TICKET);
final Cas30ServiceTicketValidator validator = new Cas30ServiceTicketValidator(this.serverPrefix);
final HttpsURLConnectionFactory factory = new HttpsURLConnectionFactory();
factory.setHostnameVerifier(this.hostnameVerifier);
validator.setURLConnectionFactory(factory);
validator.setRenew(authnRequest.isForceAuthn());
final String serviceUrl = constructServiceUrl(request, response, pair);
LOGGER.debug("Created service url for validation: [{}]", serviceUrl);
final Assertion assertion = validator.validate(ticket, serviceUrl);
logCasValidationAssertion(assertion);
return assertion;
}
示例8: authenticateUsernamePasswordInternal
import org.apache.commons.lang3.tuple.Pair; //导入方法依赖的package包/类
@Override
protected HandlerResult authenticateUsernamePasswordInternal(final UsernamePasswordCredential credential, final String originalPassword)
throws GeneralSecurityException, PreventedException {
try {
final String username = credential.getUsername();
final Pair<Boolean, Optional<Map<String, Object>>> result =
RadiusUtils.authenticate(username, credential.getPassword(), this.servers,
this.failoverOnAuthenticationFailure, this.failoverOnException);
if (result.getKey()) {
return createHandlerResult(credential,
this.principalFactory.createPrincipal(username, result.getValue().get()),
new ArrayList<>());
}
throw new FailedLoginException("Radius authentication failed for user " + username);
} catch (final Exception e) {
throw new FailedLoginException("Radius authentication failed " + e.getMessage());
}
}
示例9: invoke
import org.apache.commons.lang3.tuple.Pair; //导入方法依赖的package包/类
@Override
public Object invoke(Object target, Method method, Object[] args) throws Throwable {
Pair<Boolean, Object> result = invokeObjectMethod(target, method, args);
if(result.getKey()){
return result.getValue();
}
Request req = new Request();
req.setServiceName(serviceClass.getName());
req.setMethodName(method.getName());
req.setArgs(args);
Header header = Header.HeaderMaker.newMaker()
.make();
header.setExtend(RpcUtil.getExtend(serializeType, compressType));
RpcRequest message = new RpcRequest(header, req);
setRpcContext();
return invoker.invoke(message);
}
示例10: transferOut
import org.apache.commons.lang3.tuple.Pair; //导入方法依赖的package包/类
private ItemStack transferOut(BlockPos pos, boolean test) {
EnumFacing facing = getFacing().getOpposite();
Pair<IItemHandler, ISidedInventory> inv = getInventory(pos, facing);
if(inv.getKey() != null) {
IItemHandler handler = inv.getKey();
ISidedInventory tile = inv.getValue();
for(int slot = 0; slot < handler.getSlots(); slot++) {
ItemStack in = handler.getStackInSlot(slot);
if(!in.isEmpty() && (tile == null || tile.canExtractItem(slot, in, facing))) {
return handler.extractItem(slot, Integer.MAX_VALUE, test);
}
}
}
return ItemStack.EMPTY;
}
示例11: trunkGenOliveImpl
import org.apache.commons.lang3.tuple.Pair; //导入方法依赖的package包/类
public static int trunkGenOliveImpl(Pair<ITreeGenerator, BlockPos> p)
{
BlockPos initialPos = p.getRight();
TreeGenerator gen = (TreeGenerator)p.getKey();
int heightToGenerate = 5 + gen.worldGen.rand.nextInt(4);
int h = heightToGenerate + 1;
while (h-- > 0)
{
BlockPos pos = initialPos.up(h);
gen.worldGen.setBlockState(pos, gen.wood, 2);
gen.worldGen.setBlockState(pos.west(), gen.wood, 2);
gen.worldGen.setBlockState(pos.south(), gen.wood, 2);
gen.worldGen.setBlockState(pos.south().west(), gen.wood, 2);
}
return heightToGenerate;
}
示例12: updateConnections
import org.apache.commons.lang3.tuple.Pair; //导入方法依赖的package包/类
private void updateConnections() {
leftConnected = false;
rightConnected = false;
List<Pair<EnumFacing, IAirHandler>> connections = getAirHandler(null).getConnectedPneumatics();
for (Pair<EnumFacing, IAirHandler> entry : connections) {
if (entry.getKey() == getRotation().rotateY()) { //TODO 1.8 test
leftConnected = true;
} else if (entry.getKey() == getRotation().rotateYCCW()) {
rightConnected = true;
}
}
}
示例13: verify
import org.apache.commons.lang3.tuple.Pair; //导入方法依赖的package包/类
/**
* Verify whether the policy is accepted.
*
* @param context the context
* @param credential the credential
* @param messageContext the message context
* @return success if policy is accepted. {@link #EVENT_ID_MUST_ACCEPT} otherwise.
*/
public Event verify(final RequestContext context, final Credential credential, final MessageContext messageContext) {
final Pair<Boolean, Principal> res = repository.verify(context, credential);
context.getFlowScope().put("principal", res.getValue());
if (res.getKey()) {
return success();
}
return accept();
}
示例14: dropRemainingDrops
import org.apache.commons.lang3.tuple.Pair; //导入方法依赖的package包/类
private void dropRemainingDrops(ActionOptions option, World world) {
List<Pair<BlockPos, ItemStack>> drops = option.getDrops();
if (!drops.isEmpty()) {
for (Pair<BlockPos, ItemStack> pair : drops) {
EntityItem entityItem = new EntityItem(world);
entityItem.setItem(pair.getValue());
BlockPos pos = pair.getKey();
entityItem.setLocationAndAngles(pos.getX(), pos.getY(), pos.getZ(), 0, 0);
world.spawnEntity(entityItem);
}
}
}
示例15: run
import org.apache.commons.lang3.tuple.Pair; //导入方法依赖的package包/类
@Override
public void run() {
while (true) {
try {
// 最新拉取的值
Map<String, List<GrpcURL>> groupNewUrls = lookupServiceUpdate(group);
if (groupNewUrls != null && !groupNewUrls.isEmpty()) {
// 缓存中的值
Map<String, List<GrpcURL>> groupCacheUrls = serviceCache.getIfPresent(group);
if (groupCacheUrls == null) {
groupCacheUrls = Maps.newConcurrentMap();
serviceCache.put(group, groupCacheUrls);
}
for (Map.Entry<String, List<GrpcURL>> entry : groupNewUrls.entrySet()) {
List<GrpcURL> oldUrls = groupCacheUrls.get(entry.getKey());
List<GrpcURL> newUrls = entry.getValue();
boolean isSame = CollectionUtils.isSameCollection(newUrls, oldUrls);
if (!isSame) {
groupCacheUrls.put(entry.getKey(), newUrls);
Pair<GrpcURL, Set<NotifyListener.NotifyServiceListener>> listenerPair =
notifyServiceListeners.get(entry.getKey());
if (listenerPair != null) {
GrpcURL subscribeUrl = listenerPair.getKey();
Set<NotifyListener.NotifyServiceListener> listeners = listenerPair.getValue();
for (NotifyListener.NotifyServiceListener listener : listeners) {
ConsulRegistry.this.notify(subscribeUrl, listener, newUrls);
}
}
}
}
}
sleep(ConsulConstants.DEFAULT_LOOKUP_INTERVAL);
} catch (Throwable e) {
try {
Thread.sleep(2000);
} catch (InterruptedException ignored) {
}
}
}
}