/** * Parse a XmppAddr value as specified in RFC 6120. * * @param xmppAddr The ASN.1 representation of the xmppAddr value (cannot be null). * @return The parsed xmppAddr value. */ protected String parseOtherNameXmppAddr( ASN1Primitive xmppAddr ) { // Get the nested object if the value is an ASN1TaggedObject or a sub-type of it if (ASN1TaggedObject.class.isAssignableFrom(xmppAddr.getClass())) { ASN1TaggedObject taggedObject = (ASN1TaggedObject) xmppAddr; ASN1Primitive objectPrimitive = taggedObject.getObject(); if (ASN1String.class.isAssignableFrom(objectPrimitive.getClass())) { return ((ASN1String) objectPrimitive).getString(); } } // RFC 6120 says that this should be a UTF8String. Lets be tolerant and allow all text-based values. return ( (ASN1String) xmppAddr ).getString(); }
/** * Parses a SRVName value as specified by RFC 4985. * * This method parses the argument value as a DNS SRV Resource Record. Only when the parsed value refers to an XMPP * related service, the corresponding DNS domain name is returned (minus the service name). * * @param srvName The ASN.1 representation of the srvName value (cannot be null). * @return an XMPP address value, or null when the record does not relate to XMPP. */ protected String parseOtherNameDnsSrv( ASN1Primitive srvName ) { // RFC 4985 says that this should be a IA5 String. Lets be tolerant and allow all text-based values. final String value = ( (ASN1String) srvName ).getString(); if ( value.toLowerCase().startsWith( "_xmpp-server." ) ) { return value.substring( "_xmpp-server.".length() ); } else if ( value.toLowerCase().startsWith( "_xmpp-client." ) ) { return value.substring( "_xmpp-client.".length() ); } else { // Not applicable to XMPP. Ignore. Log.debug( "srvName value '{}' of id-on-dnsSRV record is neither _xmpp-server nor _xmpp-client. It is being ignored.", value ); return null; } }
/** * Parse a UPN value * * @param value The ASN.1 representation of the UPN (cannot be null). * @return The parsed UPN value. */ protected String parseOtherNameUpn( ASN1Primitive value ) { String otherName = null; if (value instanceof ASN1TaggedObject) { ASN1TaggedObject taggedObject = (ASN1TaggedObject) value; ASN1Primitive objectPrimitive = taggedObject.getObject(); if (objectPrimitive instanceof ASN1String) { otherName = ((ASN1String)objectPrimitive).getString(); } } if (otherName == null) { Log.warn("UPN type unexpected, UPN extraction failed: " + value.getClass().getName() + ":" + value.toString()); } else { Log.debug("UPN from certificate has value of: " + otherName ); } return otherName; } }
private String asString(ASN1Primitive primitive) { if (primitive == null || primitive instanceof ASN1Null) { return ""; } if (primitive instanceof ASN1String) { return ((ASN1String) primitive).getString(); } if (primitive instanceof DERUTCTime) { return ((DERUTCTime) primitive).getAdjustedTime(); } if (primitive instanceof DERGeneralizedTime) { return ((DERGeneralizedTime) primitive).getTime(); } if (primitive instanceof ASN1ObjectIdentifier) { switch (((ASN1ObjectIdentifier) primitive).getId()) { case "1.3.6.1.5.5.7.8.5": return "xmppAddr"; default: return primitive.toString(); } } return primitive.toString(); } }
/** * Returns the stored <code>String</code> object. * * @return the stored text as a <code>String</code>. */ public String getString() { return contents.getString(); } }
/** * Parse a XmppAddr value as specified in RFC 6120. * * @param xmppAddr The ASN.1 representation of the xmppAddr value (cannot be null). * @return The parsed xmppAddr value. */ protected String parseOtherNameXmppAddr( ASN1Primitive xmppAddr ) { // RFC 6120 says that this should be a UTF8String. Lets be tolerant and allow all text-based values. return ( (ASN1String) xmppAddr ).getString(); }
/** * Returns the stored <code>String</code> object. * * @return the stored text as a <code>String</code>. */ public String getString() { return contents.getString(); } }
public String getString() { return string.getString(); }
public String toString() { return string.getString(); }
public String getString() { return string.getString(); }
public String toString() { return string.getString(); }
/** * Gets the role name as a <code>java.lang.String</code> object. * @return the role name of this RoleSyntax represented as a * <code>java.lang.String</code> object. */ public String getRoleNameAsString() { ASN1String str = (ASN1String)this.roleName.getName(); return str.getString(); }
/** * Gets the role name as a <code>java.lang.String</code> object. * @return the role name of this RoleSyntax represented as a * <code>java.lang.String</code> object. */ public String getRoleNameAsString() { ASN1String str = (ASN1String)this.roleName.getName(); return str.getString(); }
private static String getString(ASN1Encodable attributeValue) { String string; if (attributeValue instanceof ASN1String) { string = ((ASN1String) attributeValue).getString(); } else if (attributeValue instanceof ASN1ObjectIdentifier) { string = ((ASN1ObjectIdentifier) attributeValue).getId(); } else { LOG.error("!!!*******!!! This encoding is unknown: {}", attributeValue.getClass().getSimpleName()); string = attributeValue.toString(); LOG.error("!!!*******!!! value: {}", string); } return string; }
/** * Parse a UPN value * * @param value The ASN.1 representation of the UPN (cannot be null). * @return The parsed UPN value. */ protected String parseOtherNameUpn( ASN1Primitive value ) { String otherName = null; if (value instanceof ASN1TaggedObject) { ASN1TaggedObject taggedObject = (ASN1TaggedObject) value; ASN1Primitive objectPrimitive = taggedObject.getObject(); if (objectPrimitive instanceof ASN1String) { otherName = ((ASN1String)objectPrimitive).getString(); } } if (otherName == null) { Log.warn("UPN type unexpected, UPN extraction failed: " + value.getClass().getName() + ":" + value.toString()); } else { Log.debug("UPN from certificate has value of: " + otherName ); } return otherName; } }
private String canonicalize(String s) { String value = Strings.toLowerCase(s.trim()); if (value.length() > 0 && value.charAt(0) == '#') { ASN1Primitive obj = decodeObject(value); if (obj instanceof ASN1String) { value = Strings.toLowerCase(((ASN1String)obj).getString().trim()); } } return value; }
private String canonicalize(String s) { String value = Strings.toLowerCase(s.trim()); if (value.length() > 0 && value.charAt(0) == '#') { ASN1Primitive obj = decodeObject(value); if (obj instanceof ASN1String) { value = Strings.toLowerCase(((ASN1String)obj).getString().trim()); } } return value; }
/** * Constructor. * @param roleAuthority the role authority of this RoleSyntax. * @param roleName the role name of this RoleSyntax. */ public RoleSyntax( GeneralNames roleAuthority, GeneralName roleName) { if(roleName == null || roleName.getTagNo() != GeneralName.uniformResourceIdentifier || ((ASN1String)roleName.getName()).getString().equals("")) { throw new IllegalArgumentException("the role name MUST be non empty and MUST " + "use the URI option of GeneralName"); } this.roleAuthority = roleAuthority; this.roleName = roleName; }
/** * Constructor. * @param roleAuthority the role authority of this RoleSyntax. * @param roleName the role name of this RoleSyntax. */ public RoleSyntax( GeneralNames roleAuthority, GeneralName roleName) { if(roleName == null || roleName.getTagNo() != GeneralName.uniformResourceIdentifier || ((ASN1String)roleName.getName()).getString().equals("")) { throw new IllegalArgumentException("the role name MUST be non empty and MUST " + "use the URI option of GeneralName"); } this.roleAuthority = roleAuthority; this.roleName = roleName; }
private static String parseGn(GeneralName gn) { try { if (GeneralName.uniformResourceIdentifier == gn.getTagNo()) { ASN1String str = (ASN1String) ((DERTaggedObject) gn.toASN1Primitive()).getObject(); return str.getString(); } } catch (Exception e) { LOG.warn("Unable to parse GN " + gn, e); } return null; }