use of org.gluu.oxauth.model.configuration.AppConfiguration in project oxAuth by GluuFederation.
the class CrossEncryptionTest method nestedJWTProducedByGluu.
@Test
public void nestedJWTProducedByGluu() throws Exception {
AppConfiguration appConfiguration = new AppConfiguration();
List<JSONWebKey> keyArrayList = new ArrayList<JSONWebKey>();
keyArrayList.add(getSenderWebKey());
JSONWebKeySet keySet = new JSONWebKeySet();
keySet.setKeys(keyArrayList);
final JwtSigner jwtSigner = new JwtSigner(appConfiguration, keySet, SignatureAlgorithm.RS256, "audience", null, new AbstractCryptoProvider() {
@Override
public JSONObject generateKey(Algorithm algorithm, Long expirationTime, Use use) throws Exception {
return null;
}
@Override
public JSONObject generateKey(Algorithm algorithm, Long expirationTime, Use use, int keyLength) throws Exception {
return null;
}
@Override
public boolean containsKey(String keyId) {
return false;
}
@Override
public String sign(String signingInput, String keyId, String sharedSecret, SignatureAlgorithm signatureAlgorithm) throws Exception {
RSAPrivateKey privateKey = ((RSAKey) JWK.parse(senderJwkJson)).toRSAPrivateKey();
Signature signature = Signature.getInstance(signatureAlgorithm.getAlgorithm(), "BC");
signature.initSign(privateKey);
signature.update(signingInput.getBytes());
return Base64Util.base64urlencode(signature.sign());
}
@Override
public boolean verifySignature(String signingInput, String encodedSignature, String keyId, JSONObject jwks, String sharedSecret, SignatureAlgorithm signatureAlgorithm) throws Exception {
return false;
}
@Override
public boolean deleteKey(String keyId) throws Exception {
return false;
}
@Override
public PrivateKey getPrivateKey(String keyId) throws Exception {
throw new UnsupportedOperationException("Method not implemented.");
}
});
Jwt jwt = jwtSigner.newJwt();
jwt.getClaims().setSubjectIdentifier("testing");
jwt.getClaims().setIssuer("https:devgluu.saminet.local");
jwt = jwtSigner.sign();
RSAKey recipientPublicJWK = (RSAKey) (JWK.parse(recipientJwkJson));
BlockEncryptionAlgorithm blockEncryptionAlgorithm = BlockEncryptionAlgorithm.A128GCM;
KeyEncryptionAlgorithm keyEncryptionAlgorithm = KeyEncryptionAlgorithm.RSA_OAEP;
Jwe jwe = new Jwe();
jwe.getHeader().setType(JwtType.JWT);
jwe.getHeader().setAlgorithm(keyEncryptionAlgorithm);
jwe.getHeader().setEncryptionMethod(blockEncryptionAlgorithm);
jwe.getHeader().setKeyId("1");
jwe.setSignedJWTPayload(jwt);
JweEncrypterImpl encrypter = new JweEncrypterImpl(keyEncryptionAlgorithm, blockEncryptionAlgorithm, recipientPublicJWK.toPublicKey());
String jweString = encrypter.encrypt(jwe).toString();
decryptAndValidateSignatureWithGluu(jweString);
decryptAndValidateSignatureWithNimbus(jweString);
}
use of org.gluu.oxauth.model.configuration.AppConfiguration in project oxAuth by GluuFederation.
the class ConfigurationTest method loadConfFromFile.
private static AppConfiguration loadConfFromFile(String p_filePath) throws JAXBException {
final JAXBContext jc = JAXBContext.newInstance(AppConfiguration.class);
final Unmarshaller u = jc.createUnmarshaller();
return (AppConfiguration) u.unmarshal(new File(p_filePath));
}
use of org.gluu.oxauth.model.configuration.AppConfiguration in project oxTrust by GluuFederation.
the class ConfigureLogViewerAction method updateOxAuthConfiguration.
private void updateOxAuthConfiguration() {
try {
AppConfiguration appConfiguration = jsonConfigurationService.getOxauthAppConfiguration();
appConfiguration.setExternalLoggerConfiguration(oxAuthLogConfigLocation);
jsonConfigurationService.saveOxAuthAppConfiguration(appConfiguration);
} catch (IOException e) {
log.error("Failed to update oxauth-config.json", e);
facesMessages.add(FacesMessage.SEVERITY_ERROR, "Failed to update oxAuth configuration in LDAP");
}
}
use of org.gluu.oxauth.model.configuration.AppConfiguration in project oxAuth by GluuFederation.
the class CorsFilter method init.
@Override
public void init(final FilterConfig filterConfig) throws ServletException {
// Initialize defaults
parseAndStore(DEFAULT_ALLOWED_ORIGINS, DEFAULT_ALLOWED_HTTP_METHODS, DEFAULT_ALLOWED_HTTP_HEADERS, DEFAULT_EXPOSED_HEADERS, DEFAULT_SUPPORTS_CREDENTIALS, DEFAULT_PREFLIGHT_MAXAGE, DEFAULT_DECORATE_REQUEST);
AppConfiguration appConfiguration = configurationFactory.getAppConfiguration();
if (filterConfig != null) {
String filterName = filterConfig.getFilterName();
CorsFilterConfig corsFilterConfig = new CorsFilterConfig(filterName, appConfiguration);
String configEnabled = corsFilterConfig.getInitParameter(PARAM_CORS_ENABLED);
String configAllowedOrigins = corsFilterConfig.getInitParameter(PARAM_CORS_ALLOWED_ORIGINS);
String configAllowedHttpMethods = corsFilterConfig.getInitParameter(PARAM_CORS_ALLOWED_METHODS);
String configAllowedHttpHeaders = corsFilterConfig.getInitParameter(PARAM_CORS_ALLOWED_HEADERS);
String configExposedHeaders = corsFilterConfig.getInitParameter(PARAM_CORS_EXPOSED_HEADERS);
String configSupportsCredentials = corsFilterConfig.getInitParameter(PARAM_CORS_SUPPORT_CREDENTIALS);
String configPreflightMaxAge = corsFilterConfig.getInitParameter(PARAM_CORS_PREFLIGHT_MAXAGE);
String configDecorateRequest = corsFilterConfig.getInitParameter(PARAM_CORS_REQUEST_DECORATE);
if (configEnabled != null) {
this.filterEnabled = Boolean.parseBoolean(configEnabled);
}
parseAndStore(configAllowedOrigins, configAllowedHttpMethods, configAllowedHttpHeaders, configExposedHeaders, configSupportsCredentials, configPreflightMaxAge, configDecorateRequest);
}
}
use of org.gluu.oxauth.model.configuration.AppConfiguration in project oxAuth by GluuFederation.
the class ConfigurationFactory method reloadConfFromFile.
private boolean reloadConfFromFile() {
final AppConfiguration configFromFile = loadConfFromFile();
if (configFromFile != null) {
log.info("Reloaded configuration from file: " + configFilePath);
conf = configFromFile;
return true;
} else {
log.error("Failed to load configuration from file: " + configFilePath);
}
return false;
}
Aggregations