use of org.gluu.util.security.StringEncrypter in project oxTrust by GluuFederation.
the class OpenIdClient method initInternal.
protected void initInternal() {
this.clientId = appConfiguration.getOpenIdClientId();
this.clientSecret = appConfiguration.getOpenIdClientPassword();
if (StringHelper.isNotEmpty(this.clientSecret)) {
try {
StringEncrypter stringEncrypter = StringEncrypter.instance(this.configuration.getCryptoConfigurationSalt());
this.clientSecret = stringEncrypter.decrypt(this.clientSecret);
} catch (EncryptionException ex) {
logger.warn("Assuming that client password is not encrypted!");
}
}
this.preRegisteredClient = StringHelper.isNotEmpty(this.clientId) && StringHelper.isNotEmpty(this.clientSecret);
try {
loadOpenIdConfiguration();
} catch (IOException ex) {
throw new ConfigurationException("Failed to load oxAuth configuration");
}
}
use of org.gluu.util.security.StringEncrypter in project oxCore by GluuFederation.
the class JcaDocumentStoreManualTest method main.
public static void main(String[] args) throws RepositoryException, IOException, EncryptionException {
StringEncrypter se = new StringEncrypter(StringEncrypter.DESEDE_ENCRYPTION_SCHEME, "Zqvw62DEFdhxoL4csi9hpVI4");
DocumentStoreConfiguration dsc = new DocumentStoreConfiguration();
dsc.setDocumentStoreType(DocumentStoreType.JCA);
JcaDocumentStoreConfiguration jca = new JcaDocumentStoreConfiguration();
jca.setServerUrl("http://localhost:8080/rmi");
jca.setWorkspaceName("default");
jca.setUserId("admin");
jca.setPassword(se.encrypt("admin"));
jca.setConnectionTimeout(15);
dsc.setJcaConfiguration(jca);
LocalDocumentStoreConfiguration lca = new LocalDocumentStoreConfiguration();
dsc.setLocalConfiguration(lca);
ObjectMapper om = new ObjectMapper();
System.out.println(om.writeValueAsString(dsc));
StandaloneDocumentStoreProviderFactory pf = new StandaloneDocumentStoreProviderFactory(se);
DocumentStoreProvider dsp = pf.getDocumentStoreProvider(dsc);
String doc1 = FileUtils.readFileToString(new File("V:/authorization_code.jmx"), "UTF-8");
byte[] doc2 = FileUtils.readFileToByteArray(new File("V:/scim_requests.zip"));
System.out.print("Has document: " + "/test2/test2/test.jmx: ");
System.out.println(dsp.hasDocument("/test2/test2/test.jmx"));
System.out.print("Has document: " + "/test2/test3/test3.jmx: ");
System.out.println(dsp.hasDocument("/test2/test3/test3.jmx"));
System.out.print("Write document: " + "/test2/test3/test4/test5.jmx: ");
System.out.println(dsp.saveDocumentStream("/test2/test3/test4/test5.jmx", new ByteArrayInputStream(doc2)));
System.out.print("Has document: " + "/test2/test3/test4/test5.jmx: ");
System.out.println(dsp.hasDocument("/test2/test3/test4/test5.jmx"));
System.out.print("Write document: " + "/test2/test3/test4/test5.jmx: ");
System.out.println(dsp.saveDocument("/test2/test3/test4/test5.jmx", doc1, StandardCharsets.UTF_8));
System.out.print("Has document: " + "/test2/test3/test4/test5.jmx: ");
System.out.println(dsp.hasDocument("/test2/test3/test4/test5.jmx"));
System.out.print("Read document: " + "/test2/test3/test4/test5.jmx: ");
System.out.println(dsp.readDocument("/test2/test3/test4/test5.jmx", StandardCharsets.UTF_8));
System.out.print("Read document: " + "/test2/test3/test4/test5.jmx: ");
System.out.println(IOUtils.toString(dsp.readDocumentAsStream("/test2/test3/test4/test5.jmx"), StandardCharsets.UTF_8));
System.out.print("Rename document: " + "/test2/test3/test4/test5.jmx: ");
System.out.println(dsp.renameDocument("/test2/test3/test4/test5.jmx", "/test2/test4/test5.jmx"));
System.out.print("Has document: " + "/test2/test3/test4/test5.jmx: ");
System.out.println(dsp.hasDocument("/test2/test3/test4/test5.jmx"));
System.out.print("Has document: " + "/test2/test4/test5.jmx: ");
System.out.println(dsp.hasDocument("/test2/test4/test5.jmx"));
System.out.print("Remove document: " + "test2/test4/test5.jmx: ");
System.out.println(dsp.removeDocument("/test2/test4/test5.jmx"));
System.out.print("Has document: " + "/test2/test4/test5.jmx: ");
System.out.println(dsp.hasDocument("/test2/test4/test5.jmx"));
}
use of org.gluu.util.security.StringEncrypter in project oxCore by GluuFederation.
the class WebDavDocumentStoreManualTest method main.
public static void main(String[] args) throws RepositoryException, IOException, EncryptionException {
StringEncrypter se = new StringEncrypter(StringEncrypter.DESEDE_ENCRYPTION_SCHEME, "Zqvw62DEFdhxoL4csi9hpVI4");
DocumentStoreConfiguration dsc = new DocumentStoreConfiguration();
dsc.setDocumentStoreType(DocumentStoreType.WEB_DAV);
WebDavDocumentStoreConfiguration jca = new WebDavDocumentStoreConfiguration();
jca.setServerUrl("http://localhost:8080/repository");
jca.setWorkspaceName("default");
jca.setUserId("admin");
jca.setPassword(se.encrypt("admin"));
jca.setConnectionTimeout(15);
dsc.setWebDavConfiguration(jca);
LocalDocumentStoreConfiguration lca = new LocalDocumentStoreConfiguration();
dsc.setLocalConfiguration(lca);
ObjectMapper om = new ObjectMapper();
System.out.println(om.writeValueAsString(dsc));
StandaloneDocumentStoreProviderFactory pf = new StandaloneDocumentStoreProviderFactory(se);
DocumentStoreProvider dsp = pf.getDocumentStoreProvider(dsc);
String doc1 = FileUtils.readFileToString(new File("V:/test.log"), "UTF-8");
byte[] doc2 = FileUtils.readFileToByteArray(new File("V:/test.zip"));
/*
System.out.print("Has document: " + "/test2/test2/test.jmx: ");
System.out.println(dsp.hasDocument("/test2/test2/test.jmx"));
*/
System.out.print("Has document: " + "/test2/test3/test3.jmx: ");
System.out.println(dsp.hasDocument("/test2/test3/test3.jmx"));
System.out.print("Write document: " + "/test2/test3/test4/test5.jmx: ");
System.out.println(dsp.saveDocumentStream("/test-1.jmx", new ByteArrayInputStream(doc2)));
/*
System.out.print("Has document: " + "/test2/test3/test4/test5.jmx: ");
System.out.println(dsp.hasDocument("/test2/test3/test4/test5.jmx"));
*/
System.out.print("Write document: " + "/test2/test3/test4/test5.jmx: ");
System.out.println(dsp.saveDocument("/test7.jmx", doc1, StandardCharsets.UTF_8));
/*
System.out.print("Has document: " + "/test2/test3/test4/test5.jmx: ");
System.out.println(dsp.hasDocument("/test2/test3/test4/test5.jmx"));
System.out.print("Read document: " + "/test2/test3/test4/test5.jmx: ");
System.out.println(dsp.readDocument("/test2/test3/test4/test5.jmx", StandardCharsets.UTF_8));
System.out.print("Read document: " + "/test2/test3/test4/test5.jmx: ");
System.out.println(IOUtils.toString(dsp.readDocumentAsStream("/test2/test3/test4/test5.jmx"), StandardCharsets.UTF_8));
System.out.print("Rename document: " + "/test2/test3/test4/test5.jmx: ");
System.out.println(dsp.renameDocument("/test2/test3/test4/test5.jmx", "/test2/test4/test5.jmx"));
System.out.print("Has document: " + "/test2/test3/test4/test5.jmx: ");
System.out.println(dsp.hasDocument("/test2/test3/test4/test5.jmx"));
System.out.print("Has document: " + "/test2/test4/test5.jmx: ");
System.out.println(dsp.hasDocument("/test2/test4/test5.jmx"));
System.out.print("Remove document: " + "test2/test4/test5.jmx: ");
System.out.println(dsp.removeDocument("/test2/test4/test5.jmx"));
System.out.print("Has document: " + "/test2/test4/test5.jmx: ");
System.out.println(dsp.hasDocument("/test2/test4/test5.jmx"));
*/
}
Aggregations