com.azure.core.util.serializer.JacksonAdapter - Didn't set coercion defaults as it wasn't found on the classpath - microsoft-graph-sdks

While running the below code, I'm getting error:
String clientId = "*******";
String clientSecret = "*********";
String tenant = "********";
ClientSecretCredential clientSecretCredential = new ClientSecretCredentialBuilder()
.clientId(clientId)
.clientSecret(clientSecret)
.tenantId(tenant)
.build();
TokenCredentialAuthProvider tokenCredentialAuthProvider = new TokenCredentialAuthProvider(Arrays.asList("https://graph.microsoft.com/Mail.Send"), clientSecretCredential);
GraphServiceClient graphClient =
GraphServiceClient
.builder()
.authenticationProvider(tokenCredentialAuthProvider)
.buildClient();
Error :
14:07:44.942 [main] DEBUG com.azure.core.util.serializer.JacksonAdapter - Failed to retrieve MethodHandles used to set coercion configurations. Setting coercion configurations will be skipped.java.lang.ClassNotFoundException: com.fasterxml.jackson.databind.cfg.MutableCoercionConfigat java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:606)at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:168)at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)at java.base/java.lang.Class.forName0(Native Method)at java.base/java.lang.Class.forName(Class.java:377)at com.azure.core.util.serializer.JacksonAdapter.<clinit>(JacksonAdapter.java:77)at com.azure.identity.implementation.IdentityClient.<clinit>(IdentityClient.java:94)at com.azure.identity.implementation.IdentityClientBuilder.build(IdentityClientBuilder.java:113)at com.azure.identity.ClientSecretCredential.<init>(ClientSecretCredential.java:50)at com.azure.identity.ClientSecretCredentialBuilder.build(ClientSecretCredentialBuilder.java:62)at com.optum.subropoint.subro.fp.utils.MsGraph.main(MsGraph.java:28)14:07:45.850 [main] DEBUG com.azure.core.util.serializer.JacksonAdapter - Didn't set coercion defaults as it wasn't found on the classpath.14:07:46.209 [main] DEBUG reactor.util.Loggers$LoggerFactory - Using Slf4j logging framework
I'm using ms graph api to send an email

This is not specific as to which sample you are following, Please refer these samples From the Microsoft Graph API DOCs on sending the mail with different formats and as you are using the JAVA SDK.
Please refer this DOC.Check if you are successful in sending the mail, if not please share the Client request and the time Stamp so I can check form our side whats the exact error that you are getting.
Also please check if you have provided the necessary permissions,

Related

CAS 6.5 not able to use jose4J package to validate JWT

I am upgrading from 5.3 to 6.5 and getting errors using the Jose4J package to validate the JWTs CAS is generating. From what I can tell after jose4j's JWE decrypts the JWT the content type header “cty” is “JWT” indicating that the JWT is still in a nested state and needs to again be decrypted or unsigned. The code works fine with CAS version 5.3.15. I'm using the cas overlay project and last tried version 6.5.7.
It appears that the inner JWT's content type header "cty" is set to "JWT". From my reading only the outer JWT should have it set. Is this a bug in CAS's JWT implementation?
// Step 1: signature validation
JsonWebSignature jws = new JsonWebSignature();
jws.setCompactSerialization(jwtString);
jws.setKey(new AesKey(jwtConfig.getSigningKey().getBytes(StandardCharsets.UTF_8)));
jws.setAlgorithmConstraints(AlgorithmConstraints.DISALLOW_NONE);
if (!jws.verifySignature()) {
logger.error(String.format("jwt have invalid signature:%s", jwtString));
return new ValidationDTO(false, false);
}
// Step 2: check if encryption is fine, but possibly a expired token
final byte[] decodedBytes = Base64.decodeBase64(jws.getEncodedPayload().getBytes(StandardCharsets.UTF_8));
final String decodedPayload = new String(decodedBytes, StandardCharsets.UTF_8);
final JsonWebKey jsonWebKey = JsonWebKey.Factory
.newJwk("\n" + "{\"kty\":\"oct\",\n" + " \"k\":\"" + jwtConfig.getEncriptionKey() + "\"\n" + "}");
JwtConsumer consumer = new JwtConsumerBuilder()
.setSkipAllValidators()
.setDisableRequireSignature()
.setSkipSignatureVerification()
.setDecryptionKey(new AesKey(jsonWebKey.getKey().getEncoded()))
.setJweAlgorithmConstraints(
new AlgorithmConstraints(ConstraintType.WHITELIST,
KeyManagementAlgorithmIdentifiers.DIRECT))
.setJweContentEncryptionAlgorithmConstraints(
new AlgorithmConstraints(ConstraintType.WHITELIST,
ContentEncryptionAlgorithmIdentifiers.AES_128_CBC_HMAC_SHA_256)) //this have to match CAS configuration
.build();
JwtContext context = consumer.process(decodedPayload); // <<<<< Exception thrown here. “Invalid JOSE Compact Serialization"
Invalid JWT:JWT processing failed. Additional details: [[17] Unable to process nested JOSE object (cause: org.jose4j.lang.JoseException: Invalid JOSE Compact Serialization. Expecting either 3 or 5 parts for JWS or JWE respectively but was 14.): {"clientIpAddress":"127.0.0.1","sub":"test#test2121.com","authenticationDate":1659977730,"successfulAuthenticationHandlers":"careerAuthenticationHandler","iss":"https:\/\/jason.crengland.com\/cas","userAgent":"PostmanRuntime\/7.29.2","credentialType":"UsernamePasswordCredential","aud":"https:\/\/jason.crengland.com\/cas","authenticationMethod":"careerAuthenticationHandler","geoLocation":"unknown","serverIpAddress":"127.0.0.1","exp":1660006530,"iat":1659977730,"jti":"TGT-2-xxxxxxxxx-CREJDR-MBP2022"}]
org.jose4j.jwt.consumer.InvalidJwtException: JWT processing failed. Additional details: [[17] Unable to process nested JOSE object (cause: org.jose4j.lang.JoseException: Invalid JOSE Compact Serialization. Expecting either 3 or 5 parts for JWS or JWE respectively but was 14.): {"clientIpAddress":"127.0.0.1","sub":"test#test2121.com","authenticationDate":1659977730,"successfulAuthenticationHandlers":"careerAuthenticationHandler","iss":"https:\/\/jason.crengland.com\/cas","userAgent":"PostmanRuntime\/7.29.2","credentialType":"UsernamePasswordCredential","aud":"https:\/\/jason.crengland.com\/cas","authenticationMethod":"careerAuthenticationHandler","geoLocation":"unknown","serverIpAddress":"127.0.0.1","exp":1660006530,"iat":1659977730,"jti":"TGT-2-xxxxxxxx-CREJDR-MBP2022"}]
at org.jose4j.jwt.consumer.JwtConsumer.process(JwtConsumer.java:406) ~[jose4j-0.7.12.jar:na]
at com.cre.web.security.service.JWTValidationServiceImpl.validate(JWTValidationServiceImpl.java:93) ~[classes/:na]
at com.cre.web.security.service.JWTValidationServiceImpl$$FastClassBySpringCGLIB$$c0ab6de1.invoke(<generated>) [classes/:na]
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) [spring-core-5.3.2.jar:5.3.2]
…...
at java.lang.Thread.run(Thread.java:750) [na:1.8.0_332]
Caused by: org.jose4j.lang.JoseException: Invalid JOSE Compact Serialization. Expecting either 3 or 5 parts for JWS or JWE respectively but was 14.
at org.jose4j.jwx.JsonWebStructure.fromCompactSerialization(JsonWebStructure.java:90) ~[jose4j-0.7.12.jar:na]
at org.jose4j.jwt.consumer.JwtConsumer.process(JwtConsumer.java:320) ~[jose4j-0.7.12.jar:na]
... 70 common frames omitted
Best I can tell, you are correct that the inner JWT has a content type header with "JWT". Which is incorrect and likely a problem with CAS's JWT implementation. The JwtConsumer sees that cty and tries to process the payload as a JWT (JWS or JWE) and that fails b/c the payload is JSON.
Side note that won't help with the cty issue but JwtConsumer can deal with (properly) nested JWTs so you shouldn't have to do any of the JsonWebSignature stuff. Rather build the JwtConsumer with the HMAC key and let it do that work. https://bitbucket.org/b_c/jose4j/wiki/JWT%20Examples#markdown-header-producing-and-consuming-a-nested-signed-and-encrypted-jwt shows an example of similar usage.

Examining the Windows Store apps AppxManifest at Runtime

I try to load the AppxManifest at Runtime to read out the Version of the app. I fond this article:
http://tonychampion.net/blog/index.php/2013/01/examining-the-windows-store-apps-appxmanifest-at-runtime/#comments
I tried the line from the post:
var doc = XDocument.Load("AppxManifest.xml", LoadOptions.None);
But this will throw me the following exception:
{System.Xml.XmlException: An internal error has occurred.
at System.Xml.XmlXapResolver.GetEntity(Uri absoluteUri, String role, Type ofObjectToReturn)
at System.Xml.XmlTextReaderImpl.FinishInitUriString()
at System.Xml.XmlTextReaderImpl..ctor(String uriStr, XmlReaderSettings settings, XmlParserContext context, XmlResolver uriResolver)
at System.Xml.XmlReaderSettings.CreateReader(String inputUri, XmlParserContext inputContext)
at System.Xml.XmlReader.Create(String inputUri, XmlReaderSettings settings, XmlParserContext inputContext)
at System.Xml.Linq.XDocument.Load(String uri, LoadOptions options)
at MyMedi.Src.Utilities.GetVersion()
at MyMedi.WindowsPhone.Test.Src.UtilitiesTest.Utilities_GetVersionTest()}
Can anyone tell me what I'm doing wrong?
Thanks
NPadrutt
I'm not sure why you'd want to, but you could try loading the document with the ms-appx:// uri schema in the file reference.
There's a much easier way to achieve your goal, though.
Package package = Package.Current;
PackageId packageId = package.Id;
PackageVersion version = packageId.Version;
var versionString = string.Format(
CultureInfo.InvariantCulture,
"{0}.{1}.{2}.{3}",
version.Major,
version.Minor,
version.Build,
version.Revision);

The connection to 'autodiscover.domain.com' fails using EWS

I'm trying to start work with EWS using EWS-Api-2.1 nuget package. Below is simple code I'm using:
ExchangeService _service = new ExchangeService();
_service.Credentials = new WebCredentials("mail", "password");
_service.AutodiscoverUrl("mail", url => false);//_service.AutodiscoverUrl("mail") Both variants fails
var appointment = new Appointment(_service);
appointment.Subject = "Status Meeting";
appointment.Body = "The purpose of this meeting is to discuss status.";
appointment.Start = DateTime.Now.AddHours(1);
appointment.End = appointment.Start.AddHours(2);
appointment.Location = "Conf Room";
appointment.RequiredAttendees.Add("mail1");
appointment.Save(SendInvitationsMode.SendToNone);
As result I have:
HTTP/1.1 502 Fiddler - Connection Failed
[Fiddler] The connection to 'autodiscover.domain.com' failed.
Error: ConnectionRefused (0x274d). System.Net.Sockets.SocketException
No connection could be made because the target machine actively refused it 157.56.248.169:443
In DNS management I have the following:
Initial domain: This domain is included with your account. It’s set up automatically for you, and you can’t delete it.
If you want to find out why Autodiscover is failing, I would recommend enabling tracing with all of the Autodiscover-related trace tags. Of course I'm assuming that the value "mail" that you're passing there is actually the user's email address.

Bitcoind JSON-RPC : Java Jersey Client : Unexpected end of file from server Error

I am very new to bitcoin and this is my first experiment with bitcoind.
We have been trying to develop an Java based application on BTC using bitcoind (using testnet). We are using simple HTTP Post using Jersey client with basic authentication like given below. We already have jersey client as part of project dependencies. We are running on Mac OS. The bitcoind and java client are hosted in the same system.
Client client = Client.create();
String url = "http://"+username+':'+password+"#localhost:18333";
//String url = "http://localhost:18333";
System.out.println("URL is : "+url);
WebResource webResource = client.resource(url);
Authenticator.setDefault(new Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication (username, password.toCharArray());
}
});
String input = "{\"method\":\"getblockcount\",\"params\":[],\"id\":\"1\"}";
ClientResponse response = webResource.type("application/json").post(ClientResponse.class, input);
When we execute this, we are getting
Caused by: java.net.SocketException: Unexpected end of file from server
at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:772)
at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:633)
at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:769)
From the exception what I understand is, there are some server side errors but i am not able to see errors in the log files. The degug.log does not give any details.
The entries in the bitcoin.conf file is as follows:
rpcuser=bitcoinrpc
rpcpassword=5UKQTzWTf7EEJnkShZhr9tbjpDVNmLMgQkFfWsnZhLey
testnet=1
server=1
Also I tried integrating with bitcoind using json-rpc client as well which resulted in the same error.
Really appreciate any help in resolving this error. Thank you in advance. Let me know if you need any further details.
Regards,
Manjunath
====== EDIT ======
When I inspect the request and response, its giving "Remote server closed the connection before sending response header" error as part of HTTP failure scenario. Following is the request data content :
URL : http://192.168.2.111:18333/
Request Data:
{
"method": "getblockcount",
"params": [],
"id": "1"
}
Please help me in understanding where the mistake is.
================ EDIT =================
Added below entries to bitcoin.conf to allow connections from client. But still facing the same error:
rpcallowip=192.168.2.111
rpcallowip=127.0.0.1
Regards,
Manjunath
After all tweaking, I am able to get it working properly. For the benefit of others, here is the Java Code for making JSON-RPC calls to bitcoind (Using Jersey Client):
bitcoin.conf entries :
rpcuser=bitcoinrpc
rpcpassword=5UKQTzWTf7EEJnkShZhr9tbjpDVNmLMgQkFfWsnZhLey
testnet=1
server=1
#txindex=1
rpcallowip=192.168.2.*
rpcallowip=127.0.0.1
rpcport=8999
#rpctimeout=60000
Make sure you change the port number and dont forget to provide rpcallowip entry pointing to respective IP address.
Client Code:
DefaultClientConfig config = new DefaultClientConfig();
config.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING,
Boolean.TRUE);
Client client = Client.create(config);
client.addFilter(new HTTPBasicAuthFilter(username, password));
WebResource webResource = client.resource(url);
String input = "{\"id\":\"jsonrpc\",\"method\":\"listaccounts\",\"params\":[]}";
ClientResponse response = webResource.accept("application/json").type("application/json")
.post(ClientResponse.class, input);
Thats it. Your good to start with bitcoind integration.
Regards,
Manjunath

Convert CSV to ARFF using IKVM and WEKA

CSVLoader loader = new CSVLoader();
loader.setSource(new File("));
Instances data = loader.getDataSet();
When i run above code in java , it's working fine.
But when i do the same thing in c# using the following code, it throws exception in line
weka.core.Instances instsOrg = csvLoader.getDataSet();
The exception message is" The type initializer for 'weka.core.converters.ConverterUtils' threw an exception"
string filename = "myCSVfile.csv"";
weka.core.converters.CSVLoader csvLoader = new weka.core.converters.CSVLoader();
csvLoader.setSource(new java.io.File(filename));
weka.core.Instances instsOrg = csvLoader.getDataSet();
weka.core.converters.ArffSaver saver = new weka.core.converters.ArffSaver();
saver.setInstances(data);
saver.setFile(new File("myCSVfile.arff"));
saver.writeBatch();
I have added weka.dll , IKVM.OpenJDK.Core.dll and IKVM.Runtime as references files.
Can anyone help me to get rid of this exception please???
Please reply as soon as possible :(