Java Examples for org.pac4j.core.util.CommonHelper.assertNotNull
The following java examples will help you to understand the usage of org.pac4j.core.util.CommonHelper.assertNotNull. These source code samples are taken from different open source projects.
Example 1
| Project: play-pac4j-master File: SecureAction.java View source code |
public CompletionStage<Result> internalCall(final Context ctx, final String clients, final String authorizers, final boolean multiProfile) throws Throwable {
assertNotNull("securityLogic", securityLogic);
assertNotNull("config", config);
final PlayWebContext playWebContext = new PlayWebContext(ctx, sessionStore);
final HttpActionAdapter actionAdapter = config.getHttpActionAdapter();
return CompletableFuture.supplyAsync(() -> {
return securityLogic.perform(playWebContext, config, ( webCtx, parameters) -> {
// when called from Scala
if (delegate == null) {
return null;
} else {
return delegate.call(ctx).toCompletableFuture().get();
}
}, actionAdapter, clients, authorizers, null, multiProfile);
}, ec.current());
}Example 2
| Project: vertx-pac4j-master File: LogoutHandler.java View source code |
@Override
public void handle(final RoutingContext routingContext) {
assertNotNull("applicationLogoutLogic", logoutLogic);
assertNotNull("config", config);
final VertxWebContext webContext = new VertxWebContext(routingContext, sessionStore);
vertx.executeBlocking( future -> {
logoutLogic.perform(webContext, config, httpActionAdapter, defaultUrl, logoutUrlPattern, localLogout, destroySession, centralLogout);
future.complete(null);
}, false, asyncResult -> {
if (asyncResult.failed()) {
routingContext.fail(new TechnicalException(asyncResult.cause()));
}
});
}Example 3
| Project: pac4j-master File: OidcProfileCreator.java View source code |
@Override
protected void internalInit(final WebContext context) {
assertNotNull("configuration", configuration);
configuration.init(context);
// check algorithms
final List<JWSAlgorithm> metadataAlgorithms = configuration.getProviderMetadata().getIDTokenJWSAlgs();
CommonHelper.assertTrue(CommonHelper.isNotEmpty(metadataAlgorithms), "There must at least one JWS algorithm supported on the OpenID Connect provider side");
JWSAlgorithm jwsAlgorithm;
final JWSAlgorithm preferredAlgorithm = configuration.getPreferredJwsAlgorithm();
if (metadataAlgorithms.contains(preferredAlgorithm)) {
jwsAlgorithm = preferredAlgorithm;
} else {
jwsAlgorithm = metadataAlgorithms.get(0);
logger.warn("Preferred JWS algorithm: {} not available. Defaulting to: {}", preferredAlgorithm, jwsAlgorithm);
}
if ("none".equals(jwsAlgorithm.getName())) {
jwsAlgorithm = null;
}
final ClientID _clientID = new ClientID(configuration.getClientId());
final Secret _secret = new Secret(configuration.getSecret());
// Init IDTokenVerifier
if (jwsAlgorithm == null) {
this.idTokenValidator = new IDTokenValidator(configuration.getProviderMetadata().getIssuer(), _clientID);
} else if (CommonHelper.isNotBlank(configuration.getSecret()) && (JWSAlgorithm.HS256.equals(jwsAlgorithm) || JWSAlgorithm.HS384.equals(jwsAlgorithm) || JWSAlgorithm.HS512.equals(jwsAlgorithm))) {
this.idTokenValidator = createHMACTokenValidator(jwsAlgorithm, _clientID, _secret);
} else {
this.idTokenValidator = createRSATokenValidator(jwsAlgorithm, _clientID);
}
this.idTokenValidator.setMaxClockSkew(configuration.getMaxClockSkew());
defaultProfileDefinition(new OidcProfileDefinition<>());
}