|
if anybody have soltution tell me its urgent please
|
|
|
|
|
Member 14941356 wrote: servlet problem and mapping with sql
You have hardly shared about what you are doing and the issue faced.
Please look at the forum guidelines: Java Discussion Boards
|
|
|
|
|
|
You haven't described any kind of problem so there is no way anyone is going to be able to tell you what's wrong.
You might want to start by reading this: Asking questions is a skill[^]
|
|
|
|
|
I have created a spring boot + thymeleaf application with spring security for securing the requests. The application should also be providing a rest api to communicate with other applications(other front-end framework, mobile app). For this I chose to go with OAuth2 for securing the rest api and I stumbled across keycloak which I think suits my interest.
As of now the security configuration class extends WebSecurityConfigurerAdapter and not KeycloakWebSecurityConfigurerAdapter and hence I am using the following security constraints in my application.properties :
keycloak.security-constraints[0].authRoles[0]=user
keycloak.security-constraints[0].securityCollections[0].patterns[0]=/hello
I am thinking of using spring security to secure the normal requests and use keycloak for the rest api. I want each of them to work independent of the other. That is, even if I do not have the keycloak server running I need my web app to serve the web pages(secured by spring security) and the rest API will only work when keycloak is running(secured by keycloak). Currently, the keycloak client is setup with access type : public and a redirect will be made to keycloak authentication page when I try to access any request with pattern /hello/*(these are not rest api's as of now). I will be changing the access type to bearer-only for the rest api's. I have permitted the request to /hello/ without any authentication in the configure method in spring security settings :
http.authorizeRequests()
.antMatchers("/user").hasAnyRole("ADMIN", "USER")
.antMatchers("/admin").hasRole("ADMIN")
.requestMatchers(PathRequest.toStaticResources().atCommonLocations()).permitAll()
.antMatchers("/hello").permitAll().anyRequest().authenticated().and().formLogin()
.loginPage("/login")
.defaultSuccessUrl("/", true)
.failureUrl("/login-error").permitAll().and()
.logout()
.invalidateHttpSession(true)
.logoutSuccessUrl("/login")
.logoutUrl("/logout");
Is this the right way to deal with my requirement? Should I use microservices to accomplish the same?. I am more concerned about whether it is the right way to do things regardless of whether the way I am doing would work or not. Any suggestions and/or improvements are welcome. Thanks.
|
|
|
|
|
so, i was doing some programming with eclipse and stuff. But then i noticed that all of my .JAR files suddenly looked like a pinguin with some painting stuff on his hands. i need help, cause im not sure what is going on!! I use windows.
[SOLVED] I had to right click a JAR file, and "press open in application" then select Java JDK. For some reason i had two of those...
modified 1-Sep-20 4:01am.
|
|
|
|
|
Member 14927382 wrote: (no trashmail please) Then remove your email address. You'll get a notification from the system when someone replies. No need to advertise your email.
Social Media - A platform that makes it easier for the crazies to find each other.
Everyone is born right handed. Only the strongest overcome it.
Fight for left-handed rights and hand equality.
|
|
|
|
|
Also, stop spamming.
Social Media - A platform that makes it easier for the crazies to find each other.
Everyone is born right handed. Only the strongest overcome it.
Fight for left-handed rights and hand equality.
|
|
|
|
|
You sure it's not the Linux logo?
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
That is nothing to do with Java, it's the Windows file associations. They may have been changed by eclipse. You can look at the properties and change them in Windows Explorer.
|
|
|
|
|
When executing my application, the error that indicates the title of this post sends me some idea of how I can solve it?
|
|
|
|
|
That looks like a line of code, not an error message.
Please edit your question, show the code where the problem occurs, and the complete error message. As it stands we have no idea what you are doing or what problem you are seeing.
|
|
|
|
|
You need to actually provide the error message.
Social Media - A platform that makes it easier for the crazies to find each other.
Everyone is born right handed. Only the strongest overcome it.
Fight for left-handed rights and hand equality.
|
|
|
|
|
Buenas tardes a todos.
Antes que nada, gracias por su tiempo para leer mi consulta. Realmente no se si es aquí donde tengo que hacerla.
Tengo un inconveniente al querer guardar una imagen blob en la base de datos.
El tema es así:
Tengo un pequeño código el cual toma del portapapeles la imagen y la pega en una div y a la vez, genera la ruta del blob: blob:http:
Ahora bien. Necesito guardar esa imagen en una base de datos: o bien guardarla como imagen dentro de un servidor y la ruta en una vchar o bien como base64 en un campo blob.
Cómo debo hacer?
Realmente he probado muchas cosas pero sin éxito.
Les dejo el pedazo de código que tengo.
Desde ya, muchísimas gracias!!
window.addEventListener("paste", processEvent);
function processEvent(e) {
for (var i = 0; i
Aprieta las teclas Ctrl + V para pegar el portapapeles
|
|
|
|
|
Hi, im a uk based java learner. I have bought and downloaded a few beginners books but would prefer a more structured/formal course(preferably online). There are lots of courses out there but im unsure of how good they are and which are better than others. I have limited funds and dont want to waste money on a course that wont teach me what i need to know to progress. Are there any well regarded courses(outside of universities and uk based) that anyone on here have used? I would consider distance learning at a foreign institution. Any advice would be appreciated. Cheers.
|
|
|
|
|
|
I am trying to get a simple one way Java TLS connection using the bouncycastle provider. For a couple days I have had this issue where on calling the server side SSLSocket.getInputStream() the thread hangs whereas the client side SSLSocket.getOutputStream() method is seemingly successful. In my code I generate a self signed certificate using bouncycastle which is then used in initialising the server side SSLContext with a KeyManager and the client side with a TrustManager. I have tried explicitly starting the handshake with SSLSocket.startHandshake which itself then hangs. Additionally I have spent a good deal of time making my code as similar as possible to the examples given by the BCFips manual and the Java Cryptography: Tools and Techniques book but the problem persists.
This is the security class which has methods to create the V1 certificate, generate RSA keypairs and helper methods for the aforementioned:
private static final String ASYMMETRIC_KEY_ALG = "RSA";
private static final String SYMMETRIC_KEY_ALG = "AES";
private static final String SYMMETRIC_KEY_ALG_MODE_PAD = SYMMETRIC_KEY_ALG + "/ECB/PKCS7Padding";
private static final String PROVIDER = "BC";
private static final String HASH_DIGEST_ALG = "SHA3-512";
private static final String CERT_FACTORY = "X.509";
private static final String KEYSTORE_TYPE = "PKCS12";
private static final String SIGNATURE_ALG = "SHA384with" + ASYMMETRIC_KEY_ALG;
private static final String SECURE_RANDOM_ALG = "SHA1PRNG";
private static final String AUTH_HASH_DIGEST_ALG = "PBKDF2WithHmacSHA512";
private static final File KEYSTORE_NAME = new File("/var/lib/secure-messenger-relay/keystore.p12");
private static long serialNumberBase = System.currentTimeMillis();
static{
Security.addProvider(new BouncyCastleProvider());
Security.addProvider(new BouncyCastleJsseProvider());
}
public static KeyPair generateKeyPair()
throws GeneralSecurityException
{
KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance(ASYMMETRIC_KEY_ALG, PROVIDER);
keyPairGenerator.initialize(new RSAKeyGenParameterSpec(3072, RSAKeyGenParameterSpec.F4));
return keyPairGenerator.generateKeyPair();
}
public static X509Certificate makeV1Certificate(PrivateKey caPrivateKey, PublicKey caPublicKey, String name)
throws GeneralSecurityException, OperatorCreationException
{
X509v1CertificateBuilder v1CertBldr = new JcaX509v1CertificateBuilder(
new X500Name("CN=" + name),
calculateSerialNumber(),
calculateDate(0),
calculateDate(24 * 365 * 100),
new X500Name("CN=" + name),
caPublicKey);
JcaContentSignerBuilder signerBuilder = new JcaContentSignerBuilder(SIGNATURE_ALG).setProvider(PROVIDER);
return new JcaX509CertificateConverter().setProvider(PROVIDER).getCertificate(v1CertBldr.build(signerBuilder.build(caPrivateKey)));
}
private static Date calculateDate(int hoursInFuture){
long secs = System.currentTimeMillis() / 1000;
return new Date((secs + (hoursInFuture * 60 * 60)) * 1000);
}
private static synchronized BigInteger calculateSerialNumber(){
return BigInteger.valueOf(serialNumberBase++);
}
private static byte[] getSalt()
throws NoSuchAlgorithmException
{
SecureRandom secureRandom = SecureRandom.getInstance(SECURE_RANDOM_ALG);
byte[] salt = new byte[64];
secureRandom.nextBytes(salt);
return salt;
}
}
This is the test class is where I set up the keystore and establish the connection between the server instance SSLServerSocket with accept() and the client SSLSocket instance. The code in the testSession() method is successful in calling the getOutputStream() method:
public class ReceiverClientThreadTest {
private final static String KEY_MANAGER = "SunX509";
private final static String TLS_VERSION = "TLSv1.2";
private static final String PROVIDER = "BC";
private static final String KEYSTORE_TYPE = "PKCS12";
private static KeyStore keyStore1, keyStore2, trustStore2;
private SSLSocket serverSocket;
private SSLSocket clientSocket;
@BeforeClass
public static void setUp() throws GeneralSecurityException, OperatorCreationException, IOException {
String name1 = "localhost", name2 = "client";
KeyPair kp1 = SecurityUtilities.generateKeyPair();
X509Certificate cert1 = SecurityUtilities.makeV1Certificate(kp1.getPrivate(), kp1.getPublic(), name1);
keyStore1 = KeyStore.getInstance(KEYSTORE_TYPE, PROVIDER);
trustStore2 = KeyStore.getInstance(KEYSTORE_TYPE, PROVIDER);
keyStore1.load(null, null);
keyStore1.setKeyEntry(name1, kp1.getPrivate(), "relaypass".toCharArray(), new X509Certificate[]{cert1});
trustStore2.load(null, null);
trustStore2.setCertificateEntry(name2, cert1);
}
@Before
public void init() throws IOException, GeneralSecurityException, InterruptedException, ExecutionException {
SSLServerSocket sslServerSocket = getSSLServerSocket();
SSLSocketFactory sslSocketFactory = getSSLSocketFactory();
ExecutorService pool = Executors.newFixedThreadPool(2);
Callable<SSLSocket> c1 = () -> {
return (SSLSocket) sslServerSocket.accept();
};
Callable<SSLSocket> c2 = () -> {
return (SSLSocket) sslSocketFactory.createSocket("localhost", 2048);
};
Future<SSLSocket> server = pool.submit(c1);
Thread.sleep(1000);
Future<SSLSocket> client = pool.submit(c2);
Thread.sleep(1000);
serverSocket = server.get();
clientSocket = client.get();
}
@After
public void tearDown(){
serverSocket = null;
clientSocket = null;
}
@org.junit.Test
public void testSession(){
Thread test = new Thread(new ReceiverClientThread(serverSocket));
test.start();
try (ObjectOutputStream output = new ObjectOutputStream(new BufferedOutputStream(clientSocket.getOutputStream()))) {
System.out.println("here");
}catch (IOException e){
fail();
}
}
private SSLServerSocket getSSLServerSocket() throws GeneralSecurityException, IOException {
char[] entryPassword = "relaypass".toCharArray();
KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance("PKIX", "BCJSSE");
keyManagerFactory.init(keyStore1, entryPassword);
SSLContext sslContext = SSLContext.getInstance(TLS_VERSION, "BCJSSE");
sslContext.init(keyManagerFactory.getKeyManagers(),null, null);
SSLServerSocketFactory fact = sslContext.getServerSocketFactory();
return (SSLServerSocket) fact.createServerSocket(2048 );
}
private SSLSocketFactory getSSLSocketFactory() throws GeneralSecurityException{
char[] entryPassword = "relaypass".toCharArray();
TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance("PKIX", "BCJSSE");
trustManagerFactory.init(trustStore2);
SSLContext sslContext = SSLContext.getInstance(TLS_VERSION, "BCJSSE");
sslContext.init(null,trustManagerFactory.getTrustManagers(), null);
return sslContext.getSocketFactory();
}
}
This thread which is passed the SSLSocket of the client hangs on the call to SSLSocket.getInputStream():
public class ReceiverClientThread implements Runnable {
private final SSLSocket sslSocket;
public ReceiverClientThread(SSLSocket sslSocket) {
this.sslSocket = sslSocket;
}
public void run() {
try (ObjectInputStream input = new ObjectInputStream(new BufferedInputStream(sslSocket.getInputStream()))) {
System.out.println("here");
} catch (IOException e) {
}
}
}
What could I be doing wrong as I have gone through two manuals and done my best to copy the code to the letter. I would suspect foul play in regards to the connection being over localhost but surely the fact that the Callable threads return successfully means that a connection was established and there is an issue with the handshake? Any help would be appreciated.
|
|
|
|
|
|
|
How to integrate the paypal pro version in Java
|
|
|
|
|
Never, ever, accept code from a insecure website to handle anything to do with real money.
You do not know who is giving you the code, you do not know what it does, you do not know that it places the monies correctly into the appropriate account, without passing the details to any third parties.
Only get such code from PayPal themselves - the scope for fraud otherwise is far too large. And remember, you personally could be liable for any monies lost if your action is seen to be negligent - which getting your code from a public forum would most certainly be!
Talk to them: they are pretty friendly and helpful - remember they don't make any money until you are up and running, so it's in their interest to be both!
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
I have a jframe with a jcomboBox and two buttons, the first button allows to add dynamically jcomboBoxes and the second to generate the RDF file.
the elements of comboBoxes are URIs that I extracted from an ontology.
My goal is to generate an RDF file to describe the URIs of the comboBoxes, for example I add 3 comboBoxes to my jframe by clicking on the button "add comboBox" so the final jframe will have 4 comboBoxes, for each combBoxes, I select a different URI and I click on the "generate RDF" button to generate the RDF file, but the problem is that it only works for the first URI and the other three URIs will be identical.
this is my code to add combBoxes :
add.addActionListener (new ActionListener () {
public void actionPerformed (ActionEvent e) {
c4 = new JComboBox ();
req1 ();
panel_2.add (c4);
panel_2.revalidate ();
}
this is my code to generate RDF file :
<pre>btnGenerateRdf.addActionListener (new ActionListener () {
public void actionPerformed (ActionEvent arg0) {
String u = c2.getSelectedItem (). ToString ();
String uu = c4.getSelectedItem (). ToString ();
Model model = ModelFactory.createDefaultModel ();
String u1 = u.substring (u.lastIndexOf ("#") + 1);
String str = u1.replace ('_', '');
String uu1 = uu.substring (uu.lastIndexOf ("#") + 1);
String str1 = uu1.replace ('_', '');
Resource node = model.createResource (u)
.addProperty (VCARD.N,
model.createResource ()
.addProperty (FOAF.name, str));
Resource node1 = model.createResource (uu)
.addProperty (VCARD.N,
model.createResource ()
.addProperty (FOAF.name, str1));
Resource node11 = model.createResource (uu)
.addProperty (VCARD.N,
model.createResource ()
.addProperty (FOAF.name, str1));
String s = c4.getSelectedItem (). ToString ();
if (add.getActionListeners ()! = null)
{
Resource [] nodes = new Resource [panel_2.getComponentCount () - 2];
for (int i = 0; i <panel_2.getComponentCount () - 2; i ++)
{
String s1 = s.substring (s.lastIndexOf ("#") + 1);
String s2 = s1.replace ('_', '');
nodes [i] = model.createResource (s)
.addProperty (VCARD.N,
model.createResource ()
.addProperty (FOAF.name, s2));
}}
try {
FileOutputStream fout = new FileOutputStream ("C: \\ Users \\ me \\ Desktop \\ file2.xml");
model.write (fout);
} catch (IOException e) {
System.out.println ("Exception caught" + e.getMessage ());
}
}
});
how can i fix this?
|
|
|
|
|
As far as I can see you are using fixed references to access your comboboxes. Create a List(T) for your comboboxes and add each one to the list as you create it. You can then iterate over the list and generate your data for each one as you encounter it in the loop.
|
|
|
|
|
Hi,
I am learning Java and doing some operation related to HashMap. I am trying to add details in hashmap based on city. So suppose below is the list we have :
List<Student> studentList= new LinkedList<>();
studentList.add(new Student(1, "Test1", "US"));
studentList.add(new Student(2, "Test2", "US"));
studentList.add(new Student(3, "Test3", "India"));
studentList.add(new Student(4, "Test4", "Canada"));
studentList.add(new Student(5, "Test5", "Canada"));
studentList.add(new Student(6, "Test6", "India"));
For this I am looking output something like
{US=[Test1, Test2], India=[Test3, Test6], Canada=[Test4, Test5]} mainly creating map based on Cities.
I have implemented the code for this but it's time complexity is very high so looking for some optimize solution. Can someone Please help.
private void getDetailsGroupByCity(List<Student> studentList)
{
Map<String,ArrayList<String>> studentHashMap= new HashMap<>();
List<Student> arrayList= new ArrayList<>(studentList);
List<String> names= new ArrayList<>();
Set<String> setKey= new HashSet<>();
for (Student student : arrayList) {
setKey.add(student.getCity());
}
for (String s : setKey) {
for (Student student : arrayList) {
if (s==student.getCity())
{
names.add(student.getName());
studentHashMap.put(s, (ArrayList<String>) names);
}
}
names= new ArrayList<>();
}
System.out.println(studentHashMap);
}
Thanks for your help in advance Happy Learning for me
|
|
|
|
|
You could use the SortedSet (Java Platform SE 7 )[^] which allows you to provide your own sort comparator. This means you can easily extract all the entries for each country (maybe keeping a separate List<E> of the countries.
|
|
|
|
|