|
org.apache.logging.log4j.core.config.ConfigurationException: Arguments given for element RollingFile are invalid: field 'policy' has invalid value 'null'
Check your code to see why this value is null.
|
|
|
|
|
I am trying to convert a JAVA POJO object with a JsonObject to a String as following:
class MyPojo {
public MyPojo(String sName, JsonObject obj)
{
this.sName = sName;
this.tJsonObj = obj;
}
public String sName;
public javax.json.JsonObject tJsonObj;
};
javax.json.JsonObject jsonObj = JsonUtils.toJsonObject("{\"key\": 123}");
ObjectMapper mapper = new com.fasterxml.jackson.databind.ObjectMapper.ObjectMapper();
JsonNode node = mapper.valueToTree(new MyPojo("myname", jsonObj));
String jsonStr = node.toString();
I am getting jsonStr value as:
{"sName":"myname","tJsonObj":{"key":{"integral":true,"valueType":"NUMBER"}}}
How can I get jsonStr value as:
{"sName":"myname","tJsonObj":{"key":123}}
JsonUtils.toJsonObject is my own utility method to get JsonObject from String .
|
|
|
|
|
Hi guys I created a project in android studio which has 2 types of login system the
1. Sign in with email and password
2. Login with phone number
I have a problem in login with phone number
I have 3 activities in project which in
1. I am taking the the login with email and password
2. Is I am taking the login with phone number
3. I am checking if the email is verified or not
So if the email is verified the person can go to app inside
But when I login with phone number it go to the 3rd activitiy to the email verification but I want it go to the app not to the verify email activity
Here is my code for main activity
----------
@Override
protected void onCreate(final Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mAuth = FirebaseAuth.getInstance();
currentUser = mAuth.getCurrentUser();
myViewPager = (ViewPager) findViewById(R.id.main_tabs_pager);
myTabsaccessorAdopter = new TabsAccessorAdopter(getSupportFragmentManager());
myViewPager.setAdapter(myTabsaccessorAdopter);
myTabLayout = (TabLayout) findViewById(R.id.main_tabs);
myTabLayout.setupWithViewPager(myViewPager);
}
@Override
protected void onStart()
{
super.onStart();
if (currentUser == null)
{
SendUserToLoginActivity();
}
else
{
if(!currentUser.isEmailVerified())
{
SendUserToVerifyEmailActivity();
}
}
}
private void SendUserToLoginActivity()
{
Intent loginIntent = new Intent(MainActivity.this,LoginActivity.class);
startActivity(loginIntent);
}
private void SendUserToVerifyEmailActivity()
{
Intent verifyEmailIntent = new Intent(MainActivity.this,VerifyEmailActivity.class);
startActivity(verifyEmailIntent);
}
private void SendUserToMainActivity()
{
Intent mainIntent = new Intent(MainActivity.this,MainActivity.class);
startActivity(mainIntent);
}
}
-------------------------------
And here is my PHone login code
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_register__with__phone__number_);
mAuth =FirebaseAuth.getInstance();
loadingBar = new ProgressDialog(this);
Initialize();
Second_Fourth.registerCarrierNumberEditText(Second_Fifth);
First_Fifth.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
String code = First_Fourth.getSelectedCountryCode();
First_Layout.setVisibility(View.INVISIBLE);
Second_Layout.setVisibility(View.VISIBLE);
Third_Layout.setVisibility(View.INVISIBLE);
Second_Fourth.setCountryForPhoneCode(Integer.parseInt(code));
}
});
Second_Seven.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
String phoneNumber = Second_Fifth.getText().toString();
phoneNumber = Second_Fourth.getFullNumberWithPlus();
if(TextUtils.isEmpty(phoneNumber))
{
Toast.makeText(Register_With_Phone_Number_Activity.this, "Number is recquired", Toast.LENGTH_SHORT).show();
}
else
{
loadingBar.setTitle("Phone verification");
loadingBar.setMessage("please wait...");
loadingBar.setCanceledOnTouchOutside(false);
loadingBar.show();
PhoneAuthProvider.getInstance().verifyPhoneNumber(phoneNumber,60,TimeUnit.SECONDS,Register_With_Phone_Number_Activity.this,mCallbacks);
}
}
});
mCallbacks = new PhoneAuthProvider.OnVerificationStateChangedCallbacks()
{
@Override
public void onVerificationCompleted(@NonNull PhoneAuthCredential phoneAuthCredential)
{
signInWithPhoneAuthCredential(phoneAuthCredential);
}
@Override
public void onVerificationFailed(@NonNull FirebaseException e)
{
Toast.makeText(Register_With_Phone_Number_Activity.this, "Invalid phone number", Toast.LENGTH_SHORT).show();
loadingBar.dismiss();
First_Layout.setVisibility(View.INVISIBLE);
Second_Layout.setVisibility(View.VISIBLE);
Third_Layout.setVisibility(View.INVISIBLE);
}
@Override
public void onCodeSent(@NonNull String s, @NonNull PhoneAuthProvider.ForceResendingToken forceResendingToken)
{
super.onCodeSent(s, forceResendingToken);
loadingBar.dismiss();
mVerificationId = s;
mResendToken = forceResendingToken;
First_Layout.setVisibility(View.INVISIBLE);
Second_Layout.setVisibility(View.INVISIBLE);
Third_Layout.setVisibility(View.VISIBLE);
}
};
Second_Eight.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
SendUserToRegisterNumberActivity();
}
});
Third_Fourth.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
String verificationcode = Third_Third.getText().toString();
if (verificationcode.isEmpty())
{
Toast.makeText(Register_With_Phone_Number_Activity.this, "Verification code first", Toast.LENGTH_SHORT).show();
}
else
{
loadingBar.setTitle("verification code");
loadingBar.setMessage("please wait...");
loadingBar.setCanceledOnTouchOutside(false);
loadingBar.show();
PhoneAuthCredential credential = PhoneAuthProvider.getCredential(mVerificationId,verificationcode);
signInWithPhoneAuthCredential(credential);
}
}
});
}
private void signInWithPhoneAuthCredential(final PhoneAuthCredential credential)
{
mAuth.signInWithCredential(credential)
.addOnCompleteListener(this, new OnCompleteListener<AuthResult>()
{
@Override
public void onComplete(@NonNull Task<AuthResult> task)
{
if (task.isSuccessful())
{
loadingBar.dismiss();
Toast.makeText(Register_With_Phone_Number_Activity.this, "Logged in Successful", Toast.LENGTH_SHORT).show();
SendUserToMainActivity();
}
else
{
loadingBar.dismiss();
Toast.makeText(Register_With_Phone_Number_Activity.this, "Error", Toast.LENGTH_SHORT).show();
}
}
});
}
private void Initialize()
{
First_Layout = (LinearLayout) findViewById(R.id.first_layout);
Second_Layout = (LinearLayout) findViewById(R.id.second_layout);
Third_Layout = (LinearLayout) findViewById(R.id.third_layout);
First_Fifth = (Button) findViewById(R.id.first_fifth);
Second_Seven = (Button) findViewById(R.id.second_seven);
Second_Eight = (Button) findViewById(R.id.second_eight);
Third_Fourth = (Button) findViewById(R.id.third_fourth);
First_Fourth = (CountryCodePicker) findViewById(R.id.first_fourth);
Second_Fourth = (CountryCodePicker) findViewById(R.id.second_fourth);
Second_Fifth = (EditText) findViewById(R.id.second_fifth);
Third_Third = (EditText) findViewById(R.id.third_third);
}
private void SendUserToRegisterNumberActivity()
{
Intent registernumberIntent = new Intent(Register_With_Phone_Number_Activity.this,Register_With_Phone_Number_Activity.class);
startActivity(registernumberIntent);
}
private void SendUserToMainActivity()
{
Intent mainIntent = new Intent(Register_With_Phone_Number_Activity.this,MainActivity.class);
startActivity(mainIntent);
}
}
|
|
|
|
|
3. Modify the code from the last week’s theoretical lecture (HelloWorldPanel,
HelloWorldFrame) to make a frame and a panel that show your full name
at each corner of the frame. Let the names be (MyNamePanel,
MyNameFrame) and choose whatever formats you want.
|
|
|
|
|
We didn't attend that lecture so can't really help you with your homework
|
|
|
|
|
|
servlet problem and mapping with sql
server issues
|
|
|
|
|
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.
|
|
|
|
|
|